Friday, May 15, 2009

Lexical syntax thought

We reserve the single-quote character (#\') in the Scheme lexical syntax so that it can't be used anywhere in an identifier. If you stick it in the middle of an identifier (e.g., foo'bar) it lexes as three tokens ("foo", "'", "bar"). But I don't recall ever seeing anyone make use of this fact; they always stick a space before the quote.

I really miss my precious "prime" character in ML and Haskell identifiers (let val state' = munge state ...). Scheme prides itself on a permissive lexical syntax for identifiers. Why couldn't we allow quote characters in all positions of an identifier other than the first?

P.S. I know I can use the Unicode prime character (U+2032). Sorry, not till I get my Unicode keyboard.


Richard Cobbe said...

I realize that this is probably not what you want to hear, but:

It's pretty easy to write a keyboard mapping file for MacOS that would give you access to the various super-ASCII characters (like prime) you want, usually with the use of the OPT key. Switching between keymaps is a pain, but it works -- I used this when I was writing up my dissertation's model in Unicode so I could put it in version control without latexing it all.

Let me know if you're interested in pursuing this, and I'll give you a hand.

frontline plus said...

Lexical syntax for my Thought is a tricky issue, but you put information and clarified some doubts I had. many thanks

Daniel E. Thigpen