[racket] Newbie question - Drscheme hangs on directory-exists?

From: synx (plt at synx.us.to)
Date: Fri Jul 23 22:29:21 EDT 2010

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/22/2010 01:27 AM, John Sampson wrote:
> This would mention the need to escape the backslash, which to
> a newbie like myself is not obvious.

Escaping the backslash is documented under the reader. The reader is the
program that parses your written text into something the computer can
understand. Any time you type something that Racket can't parse (and
therefore understand), you would probably benefit from reading the
documentation on the reader.

http://docs.racket-lang.org/reference/reader.html#%28part._parse-string%29

I might add that the backslash has been used as an escape character long
before a certain operating system existed called "MSDOS". It's one of
the first incompatibilies Microsoft ever employed to try and confuse and
disempower their user base, so it's understandable if you were caught
off guard by it. A standard rule is that in any programming language
anywhere ever (perl, python, racket, C, ruby, etc) when you want to
represent a string literal with a backslash in it, you must type two
backslashes.

A backslash by itself might seem like a good idea, but if you let the
backslash be by itself, without requiring \\ , you can never write a
string with just one backslash in it. Because if you write a string with
just one " character in it, that's "\"", since you must escape the quote
character to keep the string from ending prematurely. So "\" would start
reading a string literal, read an escaped quote character, then error
out because you never closed the string literal with an unescaped quote
character.

Look on the bright side at least you didn't try to check
(directory-exists? "C:\newiconSource").

..."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMSlABAAoJECC/cKf8E7UIpdEIALNIM6VVv4NtnmI98ZaHwtjM
tGDmZcHWcEdOqxIDWx76ajlaoKM73Q1ZpctiRgXUk1s+YImvQ7Z01zU3xS+qGPrn
BzLj/w2a4Y/QW9h0oyZdQJfY0YilHktkR++nH4/qmdB+CFexkoanSC/F71jAOkGn
LqaF2xbckbJjIhwdvbUBgckOcDDukNeUUxY16Bld+igo2XAANm/s0Pbx9xWIfgyk
IpyBVC03z5gImga8DgdbT16f4h5GQPwRb4IbcNw/X/ySGZ4JYehke+WeUHlA0hXe
eIIr45gJ7KRL7wH4e2P3MqlRxVS3AAw3Vd8232/InNjdlrbRimqpYRX/yrJrJBs=
=/vk2
-----END PGP SIGNATURE-----


Posted on the users mailing list.