Details
Description
See discussion here: https://groups.google.com/d/topic/clojure-dev/vZLVKmKX0oc/discussion
Summary: Duplication of ast nodes in various keys and in :children is problematic for some users. In particular, it doesn't play nicely with printing. A solution is needed which preserves "The AST is data. Period."
The attached patch makes no changes to how the sub nodes are currently stored outside of the :children key. Instead, it replaces :children values with a vector of keys into the main ast node. This preserves child ordering and allows a children function to be defined as:
(defn children [ast]
(mapcat #(if (coll? %) % [%]) ((apply juxt (:children ast)) ast)))
The attached patch has two caveats: 1) Many (but not all?) blocks will now be present in the children hierarchy as 'do forms. 2) Interleaved forms are intentionally bugged with respect to ordering. The :children vector for those forms match the actual behavior, not the expected behavior. This can be fixed along with http://dev.clojure.org/jira/browse/CLJS-288
Attachments
Activity
| Field | Original Value | New Value |
|---|---|---|
| Resolution | Declined [ 2 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
the result of the discussion did not end with agreement on representing :children as a vector of keys