rebcabin / masr

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

Confused about `binop` -- polymorphic? #34

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

Looks like binop contains polymorphic operators, valid for Real, Integer, Complex, plus some things that are valid only for Integer. Do we define tighter types for these operators? If so, how

(enum-like binop        #{'Add 'Sub 'Mul 'Div 'Pow
                          'BitAnd 'BitOr 'BitXor
                          'BitLShift 'BitRShift})
certik commented 1 year ago

Yes, for now we kept it like this. We can tighten it to real_binop, integer_binop, etc.

rebcabin commented 1 year ago

I did the following for full-form. Legacy is as in ASDL

(enum-like logicalbinop  #{'And  'Or  'Xor  'NEqv  'Eqv})
;; Collisions of names are NOT ALLOWED
;; See Legacy Sugar for RealBinOp.
(enum-like real-binop    #{'RAdd 'RSub 'RMul 'RDiv 'RPow})
(enum-like integer-binop #{'Add 'Sub 'Mul 'Div 'Pow
                           'BitAnd 'BitOr 'BitXor
                           'BitLShift 'BitRShift})
(enum-like cmpop         #{'Eq 'NotEq  'Lt  'LtE  'Gt  'GtE })
;; Collisions of names are NOT ALLOWED!
;; See Legacy Sugar for LogicalCompare.
(enum-like logicalcmpop  #{'LEq 'LNotEq})