[plt-scheme] Delimiting tokens
On Jan 30, Lauri Alanko wrote:
> However, if the s-expression is non-self-delimiting, e.g. an identifier,
> and the following character in the input is also acceptable to the
> reader, then things go wrong:
> [...]
Two obvious solutions that I used in several occasions, and IMO look
better than ~(. xxx) (which, if it's actually Scheme code in there, is
similar to ~(begin xxx)) are:
* Use something like ~{xxx} as an alternative syntax for ~xxx -- this
way you can add that when needed. (Same idea as shell variables.)
* When you're in the nested reader, parameterize the recursive `read'
by a syntax table that makes some additional characters terminate
identifiers. Good candidates are punctuations like ".", "!", "?",
and if you really want to include them in a name, you go back to the
~{xxx} thing.
(That second thing is not too uniform, but it's really easier
situations like mixing text with code. For uniform syntax, I'd just
force some terminating character in all places...
> However, this makes things ugly and verbose,
...I think that ~xxx~ looks better than ~(. xxx).)
> It's concise, logical and in line with other implementations. I
> think mzscheme's reader should support it. At least subject to a
> suitable parameter, (read-accept-dot 'initial) perhaps?
It's ugly enough that it's not worth it (IMO, of course) to confuse
people, and providing a parameter that defaults to #f seems like it
wouldn't be that much helpful since it's very easy to change the
"("-reader yourself...
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!