[racket] Racketrivia: Using ' as an identifier suffix

From: Jon Zeppieri (zeppieri at gmail.com)
Date: Thu Jan 8 15:55:08 EST 2015

I'm under the impression that * usually indicates some kind of
pluralization or Kleene star-esque behavior.

On Thu, Jan 8, 2015 at 3:53 PM, J. Ian Johnson <ianj at ccs.neu.edu> wrote:
> Indeed, I tried it for a while and didn't like it. I use * instead of ' for primes in my code. I think that's pretty common practice.
> -Ian
>
> ----- Original Message -----
> From: "robby" <robby at eecs.northwestern.edu>
> To: "Jon Zeppieri" <zeppieri at gmail.com>
> Cc: "users" <users at racket-lang.org>
> Sent: Thursday, January 8, 2015 3:45:55 PM
> Subject: Re: [racket] Racketrivia: Using ' as an identifier suffix
>
> That's a scary convention. It's hard for humans to see the difference!
>
> On Thu, Jan 8, 2015 at 2:32 PM, Jon Zeppieri <zeppieri at gmail.com> wrote:
>> You can use the unicode prime character (′) as a suffix. In DrRacket,
>> you can type that as \prime followed by ctrl-\. It would be a lot
>> nicer to map it to a simple key combo like λ is,
>>
>> -Jon
>>
>>
>> On Thu, Jan 8, 2015 at 3:15 PM, Greg Hendershott
>> <greghendershott at gmail.com> 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)
>>> -> x'
>>> 42
>>> -> (+ x' 10)
>>> '(+ x '10)
>>> -> (+ 10 x')
>>> ; readline-input:4:8: read: unexpected `)'
>>> -> (+ 10 x' )
>>> ; 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
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.