bug-apl
[Top][All Lists]
Advanced

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

Bugs (perhaps?) in behaviour of )COPY, )PCOPY with named lambda fns


From: Russtopia
Subject: Bugs (perhaps?) in behaviour of )COPY, )PCOPY with named lambda fns
Date: Fri, 9 Jul 2021 21:41:04 -0700

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


reply via email to

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