[racket] Some design "whys" of regexps in Racket
On Sat, Jun 4, 2011 at 10:30, Hendrik Boom <hendrik at topoi.pooq.com> wrote:
> On Fri, Jun 03, 2011 at 11:40:37PM -0400, Eli Barzilay wrote:
> >
> > >>> print "\"
> > [SyntaxError: ...] <-- surprise
>
> Just curious: what happens with
>
> >>> print "\""
>
> >>> "\""
'"'
The internal double quote is escaped by the backslash.
The result is just another way to write the same without need to escape:
'"'
(single, double, single quote)
And if you "print" it, you get:
>>> print "\""
"
If I am not wrong, it is the same as Racket, except for the representation
that the prompt spits out for "\" " .
Although Python's motto is "There should be one-- and preferably only one
--obvious way to do it. <http://www.python.org/dev/peps/pep-0020/>", the
language itself does one thing in two different ways, there are actually
more than 2 ways to represent that string.
You see some more "inconsistency" if you try to represent a single quote as
string:
>>> "'"
"'"
This time the internal representation of the string uses " instead of '.
[]'s
Rodolfo Carvalho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110604/9bca9bce/attachment.html>