bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Each ¨ - behavior of func without parameter


From: Jay Foad
Subject: Re: Each ¨ - behavior of func without parameter
Date: Mon, 4 Jan 2021 10:18:39 +0000

On Sun, 3 Jan 2021 at 17:08, Dr. Jürgen Sauermann
<mail@jürgen-sauermann.de> wrote:
> simple answer: {3} is niladic in GNU APL (since lack of ⍵) and monadic
> (why?) in Dyalog et al.

As far as the Dyalog parser is concerned, all dfns are ambivalent. For example:

      3{⍵}4 ⍝ left argument is consumed (but ignored because the dfn
doesn't use ⍺)
4
      {1:⍵ ⋄ ⍺+⍵}4 ⍝ parser applies dfn monadically, even though it
does mention ⍺
4

This is different from tradfns, where the Dyalog parser checks the
valence of the function before trying to execute it, and will complain
if you use the wrong number of arguments.

Inside a dfn you can use ⎕NC to tell whether it was applied monadically:
      {⎕NC'⍺'}4
0
... but this is a bit of a hack, since '⍺' and '⍵' aren't normal APL names.

As for *why* there are no niladic dfns in Dyalog, I would say it is
ideological. Dfns were invented by John Scholes when he became "sick
with desire" for functional programming, and I think he regarded
"niladic function" as an oxymoron from a strict FP point of view.

Jay.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]