rebcabin / masr

Meta ASR: replacement for aging ASDL
MIT License
4 stars 0 forks source link

introduce legacy macro for PR #19

Closed rebcabin closed 1 year ago

rebcabin commented 1 year ago

I propose to address legacy issues like quoting names with macros (will never handle foo: versus :foo -- it's a Clojure syntax error)

;; Legacy lpython/src/libasr/ASR.asdl as of 25 April 2023
;;
;; Variable(symtab_id,     name,                 identifier* dependencies,
;;          intent intent, expr? symbolic_value, expr? value,
;;          storage_type,  ttype,                abi,
;;          access,        presence,             bool value_attr)

;; Legacy macro

(s/valid?
 :masr.specs/Variable
 (Variable
  2 a []
  Local () ()
  Default (Logical 4 []) Source
  Public Required false))
;; => true

;; Heavy Sugar

(s/valid?
 :masr.specs/Variable
 (Variable--
  2 'x (Integer 4)
  nil [] Local
  [] []  Default
  Source Public Required
  false))
;; => true
rebcabin commented 1 year ago

The bigger impact is that some heavy-sugar functions will be renamed with two trailing hyphens, as in Variable--. Light-sugar functions will continue to have names with a single trailing hyphen, as in Variable-, and full form will continue to represent what we ultimately want. Legacy macros will track the "current" state of ASR as it evolves toward the ideal of MASR.