Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upCreate a comma node and add parser support #44
Conversation
xsc
self-assigned this
Mar 28, 2016
xsc
added some commits
Mar 28, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
xsc
Mar 28, 2016
Owner
@arrdem The proposal seems very reasonable to me. Also, since the next release will include a bump to the minor version anyways, I think we can include this minimally backwards-incompatible change.
I set up a branch based on yours and made the tests pass:
https://github.com/xsc/rewrite-clj/tree/arrdem/comma-nodes
Feel free to pull. :)
|
@arrdem The proposal seems very reasonable to me. Also, since the next release will include a bump to the minor version anyways, I think we can include this minimally backwards-incompatible change. I set up a branch based on yours and made the tests pass: https://github.com/xsc/rewrite-clj/tree/arrdem/comma-nodes Feel free to pull. :) |
arrdem
added some commits
Mar 28, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
arrdem
Mar 28, 2016
Contributor
Pulled your changes and pushed a few more.
As to semver... you're still on 0.n.m so I won't brook strong objection, however as a matter of principle I take great umbrage with this version pattern. 1.0.0 doesn't actually mean you're stable :P
|
Pulled your changes and pushed a few more. As to semver... you're still on |
arrdem
reviewed
Mar 29, 2016
| (reader/read-while reader reader/linebreak?)) | ||
| (node/whitespace-node | ||
| (reader/read-while reader reader/space?)))) | ||
| (let [c (reader/peek reader)] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
xsc
merged commit 4e9efd9
into
xsc:master
Mar 29, 2016
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Once #45 is merged, I'll release. |
arrdem commentedMar 27, 2016
This is more of a RFC than a finished PR, as this badly breaks the test suite and requires a change to the programming interface.
While "," is lexical whitespace in Clojure, it doesn't make sense from the perspective of indentation or rewriting tools to treat it as such. In the case of trailing commas it works ... okay. Because "," is treated as whitespace tools like cljfmt which remove trailing "whitespace" will tend to rewrite comma paired maps. From the indenter's perspective there really isn't a good logical way around this, as preserving trailing commas requires introspecting and rewriting trailing whitespace to minimize it, rather than simply understanding that
#",+"is significant whitespace which should not simply be discarded.I consider the two following cases to be "correct" understandings of "," usage.
Ex 1.
{:foo :bar, :baz :qux}Ex 2.
Neither of which is enabled by the present strict understanding of "," as whitespace.
This PR has the following impact:
#"\s+"whitespace?predicate so that comma nodes are treated as whitespaceBecause of the last refactor, this is technically a breaking change. I personally don't think it makes sense to overload the existing whitespace-node constructor to potentially generate several nodes rather than one, but the consequence is that consumers are now expected to make use of whitespace-nodes in order to achieve the same semantics😞
However this enables tooling to opt into treating "," specially using the
comma?predicate while preserving existing behavior derived from thewhitespace?predicate.