@lee I made a metadata-related change to sci. This might help with the metadata-related issue you had a while ago when testing rewrite-clj with sci
Oh cool, thanks @borkdude, I will have a look soon! I just recently finished a change that, by default, elides reader generated location metadata on coercion from form to rewrite-cljc meta node. I had it also cover sci’s :end-line
and :end-column
.
kewl :)
This change made testing under sci easier for me.
yeah, right now if the user does (with-meta ... {:foo 1})
in sci, ...
will only contain {:foo 1}
as metadata, nothing else
whereas before it kept the line and column metadata
Ah… that makes sense.
this had to do with a security option, but now changed the implementation for that
I ran into this when I wanted to expose grasp to a CLI which also uses sci to parse code ... it's a bit meta, but this resulted in wrong line information in the output
Cool, I’m just about to start updating my rewrite-cljc design notes on namespaced things… I’ll ping back for your input after done!
Detail:
$ cat /tmp/fn_literal.clj
(require '[clojure.pprint :as pprint]
'[clojure.spec.alpha :as s]
'[clojure.string :as str]
'[grasp.api :as g])
(s/def ::spec (fn [x]
(and (seq? x)
(= 'fn* (first x))
(> (count (second x)) 1)
(some-> x meta :source (str/starts-with? "#(")))))
(let [matches (g/grasp g/*path* ::spec {:source true})
rows (map (fn [match]
(let [m (meta match)]
{:source (:source m)
:match match
:url (:url m)
:line (:line m)}))
matches)]
(pprint/print-table
[:url :line :source :match]
rows))
$ script/run-cli - /tmp/fn_literal.clj <<< "#(foo %1 %2)"
| :url | :line | :source | :match |
|-------+-------+--------------+---------------------------|
| stdin | 1 | #(foo %1 %2) | (fn* [%1 %2] (foo %1 %2)) |
This would output line 14 before because the local match
had line number 14 ;)Ha, that’s funny, I spent a good while the other day staring https://github.com/borkdude/sci/blob/4d8d05096975a66be312ba2162d04fc53ca6b761/src/sci/impl/interpreter.cljc#L611. I guess it is unused now?
yeah, it's unused, I just forgot to remove it. Will do now
done
@borkdude, I made an initial pass through my https://github.com/lread/rewrite-cljc-playground/blob/lread-ns-kw-map/doc/design/01-merging-rewrite-clj-and-rewrite-cljs.adoc#-namespaced-maps-and-keywords---in-progress for rewrite-cljc. I expect they will benefit from additional pass with a refreshed Lee-brain tomorrow. I’ll ping you again after I’ve done that. Note that GitHub does not do a great job of rendering my adoc here… so you might want to try an alternate viewer.
@lee That's quite a document!
@borkdude Hah! Hopefully the namespaced elements section is not too long to digest. I shall try to slim it down further later tomorrow.
@lee This section right?
https://github.com/lread/rewrite-cljc-playground/blob/lread-ns-kw-map/doc/design/01-merging-rewrite-clj-and-rewrite-cljs.adoc#node-creation
My initial reaction:
It feels more natural to me to have (map-node children)
and (map-node children opts)
I like it when args don't shift position when you have a +1 arity.
I'm not too fond of the {:type :literal}
approach. I think auto-resolved is the appropriate term for it. When it's not auto-resolved, it doesn't refer to a namespace alias.
So I would go with opts being {:auto-resolved true/false :prefix "..."}
and store these as simple fields (not maps) in the defrecord type:
(defrecord MapNode [children prefix auto-resolved])