Open rebcabin opened 1 year ago
I think we should get rid of aliases. I started with that in AST, being inspired by LISP (!!), to have nodes like (+ 1 2)
instead of (BinOp 1 Add 2)
. But after quite a lot of experience with AST and ASR printouts, I think it is not worth it. It is much better to be 100% consistent and always use the full names. This is done here and we should get rid of it: https://github.com/lcompilers/lpython/blob/2c5034a299c7ec3edcd6bb13daab1434b8e6d0cc/src/libasr/asdl_cpp.py#L1239
Note that the node you want is called Assignment
(such as x = 3
), not Assign
(which is a Fortran Assign statement), see https://github.com/lcompilers/lpython/issues/1467.
Thanks for the answer. I'm leaving this open as a tracking issue for getting rid of the subs. The goal of (at least our new Clojure work) is for ASR to be machine-checkable, not just human-readable, and subs introduces "another layer of mapping."
my ad-hoc "mapping layer":
(def expr2-lpy "examples/expr2.py")
(def expr2-clj
(walk/prewalk
(fn [node]
;; see https://github.com/lcompilers/lpython/issues/1466
(cond (= node '=)
'Assignment
:else
node))
(lpython/get-sample-clj expr2-lpy)))
I use ASR.adsl to generate ASR processor functions. I read ASR.adsl and find a
stmt
node namedAssign.
Then I print
lpython --show-asr --no-color examples/expr2.py
and find, in thebody
slot of a function, (edited)That messes me up as I must now write a spec for
=
by hand instead of automatically reading it out of ASR.adsl.It also undermines my confidece ... how many other ASR terms have undocumented aliases?