Unexpected "#_ - Discard" error

48 views
Skip to first unread message

zen...@gmail.com

unread,
Apr 3, 2021, 9:50:49 AM4/3/21
to Clojure
I'm reading https://clojure.org/guides/weird_characters#_discard and run into this error:

user> #_({1:2})
Syntax error reading source at (REPL:247:14).
Invalid number: 1:2

Ty.

Alex Miller

unread,
Apr 3, 2021, 10:46:42 AM4/3/21
to Clojure
The discard reader will read, then discard (so the following form still has to be readable). In this case, the 1:2 starts with a number so is parsed as one, but that's an invalid form.
Message has been deleted

zen...@gmail.com

unread,
Apr 3, 2021, 1:09:49 PM4/3/21
to Clojure
Thank you for the clarification. I'll use ';' instead.

The docs suggest that "The form following #_ is completely skipped by the reader (This is a more complete removal than the comment macro which yields nil).". This can prove useful for debugging situations or for multiline comments.

Laurens Van Houtven

unread,
Apr 3, 2021, 1:22:10 PM4/3/21
to clo...@googlegroups.com
#_ is a reader macro—so what’s inside still has to be syntactically valid (to the reader).

When trying to parse the literal, presumably because it ends and/or starts with a digit, it is incorrectly interpreted as a number. It’s presumably missing a space depending on what you intended that literal to mean.

lvh


Ty.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/4d306d9a-c030-4387-b92d-8e6fb2d5b63an%40googlegroups.com.
--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages