Main icon indicating copy to clipboard operation
Main copied to clipboard

Define When Operand's Order is Important in Leonidas

Open dormaayan opened this issue 9 years ago • 4 comments

  • For Commutative infixExpressions ignore the order of operands
  • For non-Commutative force specific order as was in the pattern.
  • Support both cases of 2 operands and also more than 2 operands

dormaayan avatar Dec 13 '16 20:12 dormaayan

You probably thought about it but note that && and || are not commutative although that logically they are... But sometimes we would like to have a tipper which doesn't care about the order between && expression (for example- 'a' <= c && c <= 'z'), so if you could still support an option to cancel non-commutativity in some cases that would be great!

orimarco avatar Dec 14 '16 06:12 orimarco

@orimarco : Yes, after I thought about it yesterday I understood that there are many cases that we need to force the order of the operands, especially in cases that the same variable appear more than one time in the code, for example here :

add(TipperFactory.patternTipper("$X == 0 ? 0 : 1", "Bit.of($X)", ""));

here that is really important that we will force the right order in order to know what is the value of $X So, I will force order as a default and will add option to do ignore that in commutative operands.

dormaayan avatar Dec 14 '16 06:12 dormaayan

Note that there is a function "as.bit(x)", we may also want "sign.of(x)", which returns 0,1,-1

yossigil avatar Dec 14 '16 08:12 yossigil

@orimarco ? What's up with this?

yossigil avatar Apr 28 '17 06:04 yossigil