Hi,
in following up the recent email discussions with Jay Foad and
Hans-Peter Sorge,
I have changed the operator-to-operator binding in GNU APL. SVN
1367.
Before the change an _expression_ with 2 adjacent operators,
for example 2 /
/ 3 4⍴5, would have given this:
B←3 4⍴5
2 / / B
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5·
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5·
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5·
GNU APL would have bound the left / to the right / and evaluation
the _expression_ with:
* the left / being function compress, and
* the right / being operator reduce with function compress as left
operand.
After the change the same _expression_ now evaluates to:
B←3 4⍴5
2 / / B
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
GNU APL now binds 2 to / as discussed earlier. This creates a
derived function,
say TWICE, like:
∇ Z←A TWICE B
⍝ A not used
Z←2 / B
∇
and then reduces TWICE with B:
TWICE / B
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
Interestingly:
* as seen above, TWICE / B and 2 / / B now give
the same result in GNU APL,
* TWICE / B gives the same result in GNU APL and in
IBM APL2,
but: 2 / / B gives a DOMAIN ERROR
in IBM APL2, and
* TWICE / B also give the same results in GNU APL
and in Dyalog APL,
but Dyalog APL gives a different result (apparently the same as
the old
GNU APL implementation) for 2 / / B (from tryapl.org):
B←3 4 ⍴ 5
TWICE←{⍺ ⊢ 2/⍵}
TWICE / B
┌───────────────┬───────────────┬───────────────┐
│5 5 5 5 5 5 5 5│5 5 5 5 5 5 5 5│5 5 5 5 5 5 5 5│
└───────────────┴───────────────┴───────────────┘
2 / / B
┌─────────┬─────────┬─────────┐
│5 5 5 5 5│5 5 5 5 5│5 5 5 5 5│
├─────────┼─────────┼─────────┤
│5 5 5 5 5│5 5 5 5 5│5 5 5 5 5│
├─────────┼─────────┼─────────┤
│5 5 5 5 5│5 5 5 5 5│5 5 5 5 5│
└─────────┴─────────┴─────────┘
That suggest that the binding of operators is not very portable
between interpreters and one should not rely on them in the first
place. It seems to be more reliable bind explicitly as shown above
as to avoid unexpected surprises later on.
Best Regards,
Jürgen
- Operator binding Dr . Jürgen Sauermann
- Re: Operator binding Jay Foad
- Re: Operator binding Elias Mårtenson
- Re: Operator binding Jay Foad
- Re: Operator binding Dr . Jürgen Sauermann
- Fwd: Operator binding Hans-Peter Sorge
- Re: Fwd: Operator binding Dr . Jürgen Sauermann
- Re: Fwd: Operator binding Hans-Peter Sorge
