Left, Right, or the Same?

Something that was talked about at the November meeting of London-based APL users was that it might be useful for the APL Wiki to contain summaries of online discussions which had happened at places like comp.lang.apl and the dyalogusers mailing list. This is a first attempt at such a summarisation, brought about by suggestions that Dyalog might introduce some new primitive functions. If you don't like it, feel free to change it - if you really don't like it, feel free to delete it.

Left, Right Dyadic Forms

Both Sharp APL and J have for some time included primitive functions which returned either their left or right arguments (unchanged). There was little contention about these dyadics aside from naming, some preferring to follow the Sharp APL "lev" and "dex", others preferring J's "left" and "right".

The symbols proposed are ⊣ and ⊢ respectively.

Notice that these functions are quite different from APL2's "left" and "right".

Monadic Form

Agreement on the monadic(s) was less uniform, partly because Sharp APL offered a different model from J.

Some participants preferred the Sharp model, where monadic "lev" offered a black hole into which unwanted results could be thrown.

Others preferred the J model, where monadic ] and monadic [ are both called "same" and do nothing.

Some participants found it hard to see much utility for the monadic form.

While most versions of APL react to monadic + and a non-numeric argument with DOMAIN ERROR (consistent with dyadic + and non-numeric arguments), Dyalog has long allowed this case and returns the argument unchanged - it is equivalent to "same" in this case. Monadic + on an numeric argument is also an identity, for real numbers.

What makes this matter is that Dyalog might at some point introduce complex numbers, meaning that monadic + should no longer be an identity. Going forward (as we dynamic business leaders say) this ought not be a problem, because monadic "same" offers identity for all arguments.

But, some code exploits Dyalog's specific domain extension and may begin to fail if and when complex numbers are introduced. At this point there has been no resolution of this issue - opinions are divided about whether backward compatibility to what might be considered a design error should be adopted.


CategoryEssays