@@ 40,11 40,7 @@ struct[ Result
CONST of = arg i) endof
_err endcase ;
: :isconst? ( self -- f ) type CONST = ;
- \ Sort two result in "correct" order. If one of the ops is a W, it goes left.
- \ If any of the results is a const, it goes right. After a :?swap, you can
- \ check if both args are const by only checking the left one.
- : :?swap ( left right -- left right )
- dup type W = if swap else over :isconst? if swap then then ;
+ : :isW? ( self -- f ) type W = ;
]struct
alias noop parseExpression ( tok -- res ) \ forward declaration
@@ 93,9 89,10 @@ UOPSCNT wordtbl _tbl ( res -- res )
endcase ;
current ' parseFactor realias
-: binop doer ' , does> @ ( left right w ) >r
- Result :?swap over Result :>W Result :hal# r> execute ;
-binop _+, +, binop _*, *,
+\ ops that can freely swap their operands
+: swappable doer ' , does> @ ( left right w ) >r
+ dup Result :isW? if swap then over Result :>W Result :hal# r> execute ;
+swappable _+, +, swappable _*, *,
: _=, ( left right ) Result :>W Result :hal# !, Result :W ;