Opting Out of Math Functions With VOID

It seems to me that it could be useful if math operations accepted VOID.

>> factor: null

>> coefficient: 10

>> value: multiply factor coefficient
** Error: multiply doesn't allow ~null~ antiform for its value1 argument

>> multiply maybe factor coefficient
== 10

>> add coefficient maybe factor
== 10

If you opt out of the left hand side of a subtraction, you'd get negation:

>> subtract maybe factor coefficient
== -10

If you opt out of the left side of a division, er... hm. That should probably be an error.

>> divide maybe factor coefficient
** Error: divide doesn't allow ~void~ antiform for its value1 argument

If you opt out of both arguments you get null.

>> add maybe factor maybe factor
== ~null~  ; anti

I suppose divide can allow you to opt out of both arguments, though it makes the interface suggest the dividend can be opted out of in isolation since it would have void in the accepted types solely to handle the both-opt-out case.

Seems Useful and Supports My Cautious Attitude on VOID

I now believe CASE and SWITCH etc. that do not take any branches should return NULL. So you're less likely to be bitten by stray voids being tolerated in such situations, and need an explicit MAYBE.

But IF will still return void.

>> multiply 10 (if 1 > 100 [20])
== 10

I’m not sure I see how this could be useful. But I’m not hugely opposed to it either.

>> factor: null

>> coefficient: 10

>> x: if factor [add coefficient factor]
== ~void~  ; anti

>> x: add coefficient either factor [factor] [0]
== 10

>> x: add coefficient maybe factor
== 10
  • Expression produces the calculation product.

    • You don't get that if you put the conditional on the outside--in the case the branch isn't taken.
  • Keeps you from having to repeat your variable name twice.

With proposed shorthand (people don't have to use it if they don't want to...)

>> x: add coefficient ? factor
== 10