Ah, that all makes sense. I hadn't considered the differing return types for )ERASE vs. ⎕EX, that is useful.
Thank you, -Russ On Sat, 10 Jul 2021 at 07:05, Dr. Jürgen Sauermann <mail@jürgen-sauermann.de> wrote: > Hi, > > I believe this is simply a misunderstanding of functionality. > > Consider this (something similar happens if you )COPY the same script > twice): > > * )CLEAR** > ** FOO←{ 42 ⊣ ⍵ } ⍝ OK: create monadic defined function FOO > (which returns 42)** > ** FOO←{ 42 ⊣ ⍵ } ⍝ ERROR: FOO is now a defined function, so you > cannot assign anything to it.** > **SYNTAX ERROR** > ** FOO←λ1** > ** ^ ^* > > As matter of protection, in GNU APL you cannot re-define a named lambda > without erasing it. > You can (and in most cases should), however, localize it. > > As to )ERASE vs. ⎕EX: use )ERASE in immediate execution mode (preferably > after )SIC) > and ⎕EX in defined functions. In immediate execution (which includes > scripts) it is a matter > of preference which one you use and in which fashion you want to get the > success of the of > the operation (error text for failed )ERASE or a boolean vector for ⎕EX). > > Best Regards, > Jürgen > > > On 7/10/21 6:41 AM, Russtopia wrote: > > I have noticed what I believe are some inconsistencies (bugs?) with > > how GNU APL handles reloading/overwriting/erasing of symbols which are > > 'trad fns' versus 'lambda fns'. > > > > Consider the following )DUMP file: > > > > --8<-- > > #!/usr/local/bin/apl --script > > ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ > > ⍝ ⍝ > > ⍝ sink.apl 2021-07-09 20:04:14 (GMT-8) ⍝ > > ⍝ ⍝ > > ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ > > > > Life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵} > > > > ∇a←MatToVecArray M > > ⍝⍝ Return rows in M as an array of vectors > > ⍝⍝ lambda (dfn) version: {(⊂⍺){⍺[⍵;]}¨⍳≢⍵} ⍝⍨M > > a←{⊂M[⍵;]}¨⍳≢M > > ∇ > > --8<-- > > > > The above will )LOAD and )LOAD a second time, without error (as I > > presume it totally overwrites the current WS). However, )COPY or > > )PCOPY will give an error for the 'Life' function if it is already > > loaded into the current WS: > > > > )copy sink Life > > DUMPED 2021-07-09 20:04:14 (GMT-8) > > )copy sink Life > > DUMPED 2021-07-09 20:04:14 (GMT-8) > > SYNTAX ERROR > > Life←λ1 > > ^ ^ > > > > Regular 'trad fns' can be re-loaded into the current WS without issue. > > > > If I add in > > > > ⎕EX 'Life' > > > > to sink.apl above the definition, )COPY and PCOPY will now succeed; > > but if I )DUMP this WS back to file, the ⎕EX is not part of the )DUMP > > output so problems will re-occur. > > > > As an final note, as an APL newcomer: When is it preferable to use ⎕EX > > instead of )ERASE ?) > > > > Thanks, > > -Russ > > > >