-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add #_ discard syntax #1354
add #_ discard syntax #1354
Conversation
I think the simplest way to do this is with postprocessing. Allow N.B. I'd recommend against changing |
Here's another approach that doesn't change the grammar so much. All term productions now produce a list, and a discarded term produces an empty list. With this approach (so far), there are places where |
I found a simpler grammar change. This time it only adds a few productions and leaves the existing ones alone. |
Seems pretty cool to me. |
I'll start rounding it out then. Tests, |
It doesn't matter very much so long as you commit documentation, NEWS, and tests after (or at the same time as) the corresponding changes to the code. Everything in one big commit is also a reasonable option. As for the order in which you actually write stuff, the order you listed seems like the most natural one, with "tests for |
I thought that |
I made this to be Hy's equivalent of Clojure's
That said, why not just use |
¯\_(ツ)_/¯ Okay, it's got a dead-simple implementation in any case. Otherwise, everything looks good to me. You might want tests for |
I added more tests. |
docs/language/api.rst
Outdated
It's often more useful than linewise comments for commenting out a | ||
form, because it respects code structure even when part of another | ||
form is on the same line. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include an example, and write out "Extensible Data Notation". I didn't know what "EDN" stands for, and I bet that most other readers won't, either.
docs/language/api.rst
Outdated
be grammatically valid Hy, so the compiler can tell where the comment ends. | ||
Besides the semicolon linewise comments, | ||
Hy also has the ``#_`` discard prefix syntax to discard the next form. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of comment
would be good, too.
Closes #1058.
This still needs docs, a
comment
macro, and lots of tests. [Edit: and a news mention!] But I'd like to verify my approach first.The
#_
syntax needs to be at the "reader" level. It can't be a simple macro. The lexer is too low-level for this. A regex is enough for;
comments, but the#_
syntax needs to be able to identify Hy forms properly, even when they contain nested brackets. So I added an "empty" production to the grammar in the parser to make it work.I had to add the "empty" production in a lot of places to avoid shift/reduce warnings. This does complicate the parser a bit. If someone has a more elegant approach, I'd like to see it.