You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This metadata is not in the original source code. It is added by the reader.
A more obscure use case is under sci (and therefore also babashka).
Sci adds positional metadata :line, :column, :end-line and :end-column to all elements that accept metadata.
> bb --repl
Babashka v0.2.3 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (meta '(123))
{:line1, :column7, :end-line1, :end-column15}
user=> (meta [456])
{:line3, :column7, :end-line3, :end-column14}
user=> (meta #{123})
{:line5, :column7, :end-line5, :end-column15}
user=>
For rewrite-cljc, this metadata manifests itself problematically during coercion from Clojure form to rewrite-cljc node.
Proposed Solution
I think that suppressing well known reader metadata by default would be less surprising to users of rewrite-cljc.
This is technically a breaking change in default behavior. I can only imagine existing rewrite-clj users who have stumbled against this behavior would have special code to work around it.
If a user of rewrite-cljc, for some reason, felt a need to preserve the existing rewrite-clj behavior, we could support that with a dynamic variable. Perhaps rewrite-cljc/*elide-metadata* would default to [:line :column :end-line :end-column] but could be overridden to nil to offer a route to backwards compatibility. But on second thought, I think we'll just hardcode the eliding; the behaviour of including it, can be rationalize as a bug.
This change would:
help mainstream users of rewrite-cljc under Clojure avoid an oddity in handling of quoted lists.
simplify my sci tests; it would allow me to abandon my sci fork (which compensates from some metadata handling) and use sci master in a more straightforward manner.
Alternative Solutions
None, at present.
Action
I will experiment with above idea, and if fruitful, will effect the change.
The text was updated successfully, but these errors were encountered:
Adapated from lread/rewrite-cljc-playground#63, fix to be reapplied to rewrite-clj
Problem/Opportunity
Rewrite-clj and therefore rewrite-cljc automatically coerces metadata to nodes.
When the metadata comes from the reader rather than the actual source code, this might cause confusion (see #37).
For example in Clojure,
:line
and:column
metadata are added to quoted lists:This metadata is not in the original source code. It is added by the reader.
A more obscure use case is under sci (and therefore also babashka).
Sci adds positional metadata
:line
,:column
,:end-line
and:end-column
to all elements that accept metadata.For rewrite-cljc, this metadata manifests itself problematically during coercion from Clojure form to rewrite-cljc node.
Proposed Solution
I think that suppressing well known reader metadata by default would be less surprising to users of rewrite-cljc.
This is technically a breaking change in default behavior. I can only imagine existing rewrite-clj users who have stumbled against this behavior would have special code to work around it.
If a user of rewrite-cljc, for some reason, felt a need to preserve the existing rewrite-clj behavior, we could support that with a dynamic variable. Perhaps
rewrite-cljc/*elide-metadata*
would default to[:line :column :end-line :end-column]
but could be overridden tonil
to offer a route to backwards compatibility. But on second thought, I think we'll just hardcode the eliding; the behaviour of including it, can be rationalize as a bug.This change would:
Alternative Solutions
None, at present.
Action
I will experiment with above idea, and if fruitful, will effect the change.
The text was updated successfully, but these errors were encountered: