-i as an identifier

28 views
Skip to first unread message

Sage Gerard

unread,
Sep 10, 2020, 6:40:50 PM9/10/20
to Racket Users
It looks like -i cannot be used as an identifier because it evaluates to the complex number 0-1i. So in the v7.8 REPL, (define -i "foo") fails. I noticed this when trying to map CLI flag strings to identifiers. -i was the only one in the set to fall over.

In the Reading Numbers section of the reference, it looks like a digit sequence is required before "i" for both the inexact complex and exact complex productions. That makes sense to me because it doesn't seem right to assume that an empty string corresponds to -1 like it seems to do here. Maybe I'm misreading the grammar?

Before I open a GitHub issue, I just need to know if any part of this is unintentional.

~slg


Sorawee Porncharoenwase

unread,
Sep 10, 2020, 8:27:59 PM9/10/20
to Sage Gerard, Racket Users

I think you read the doc correctly, but there are programs that use +i and -i, so it's unclear if fixing the reader is desirable. Perhaps the documentation should be adjusted instead.

Here’s an example of how people use +i and -i: https://github.com/mbutterick/aoc-racket/blob/master/2019/03.rkt#L20


--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/s9pqyR4hlcTjjfYYHeNqnVsDKbU138qdy-L0rIquew86_TtTNX4SlRRw2r4Yv2-0szTzJiCmyu4QDmwwfPD863HHRO6oZpT9x1V8GfCmM3E%3D%40sagegerard.com.

Robby Findler

unread,
Sep 10, 2020, 10:01:31 PM9/10/20
to Sorawee Porncharoenwase, Sage Gerard, Racket Users
Reply all
Reply to author
Forward
0 new messages