On Jan 8, 2015, at 3:15 PM, Greg Hendershott <[email protected]> wrote:
> So Haskell conventionally uses ' as a suffix, prime. From what I've > seen, Scheme and Racket tend to use * instead. > > At some point I "learned" that you cannot use ' as a suffix in Racket. > > Today I tried again, and was surprised to see that it works... somewhat. > > $ racket > Welcome to Racket v6.1.1.6. > -> (define x' 42) This definition introduces x as '42. Works like a charm > -> x' This reference derefs x, which is 42. And it introduces a ' into the io stream. > 42 > -> (+ x' 10) Here the quote is applied to an S-expression and you get exactly the expected result. > '(+ x '10) > -> (+ 10 x') This is + 10 x [as defined above] and the ' token. There is one place where it can't appear: to the left of a ) > ; readline-input:4:8: read: unexpected `)' > -> (+ 10 x' ) Same here. ;; --- In principle, ' would be good to use as part of a name but I prefer to use it for quoted S-expressions if that's the choice I have. Then again, I'd be willing to give up ' in favor of ` if this didn't have performance problems. -- Matthias > ; readline-input:5:8: read: unexpected `)' > > > 0. It turns out x' _is_ a valid identifier, and it self-evaluates just > fine. Interesting. > > 1. I don't understand why (+ x' 10) evaluates not to 52, and not even > an error, but... '(+ x '10). WAT. > > 2. Less surprising to me is that (+ 10 x') and even (+ 10 x' ) are > errors. But actually, I wonder why the reader (or lexer?) couldn't > handle ' followed by a character that can't be part of an identifier? > > > p.s. I'm not proposing this would be a great suffix style to use. > Quick, distinguish x' from 'x ! And don't type one when you mean the > other! I get that. Even so, I'm curious. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users

