[Top][All Lists]

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

Re: [Bug-apl] Local sysvars in lambdas

From: Juergen Sauermann
Subject: Re: [Bug-apl] Local sysvars in lambdas
Date: Fri, 26 Aug 2016 15:41:08 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hi Louis,

so I suppose this was not an issue.

BTW if you believe a lambda behaves differently than a defined function then
you can check the lambda with *⎕CR*, e.g.:

**      ⎕CR 'ADD'**
**λ←⍺ λ1 ⍵;C;⎕IO;D*
*λ←⍺+⍵ *

Or, in your example:

*      f←{⍎(⍵>1)⊃'⍵' '⍵×⍙ ⍵-1'⊣⎕IO←0;⎕IO}**
**      ⎕CR 'f'**
**λ←λ1 ⍵;⎕IO **
**λ←⍎(⍵>1)⊃'⍵' '⍵×⍙ ⍵-1'⊣⎕IO←0*

In GNU APL a lambda is turned into a normal defined functions right after its body was parsed.

/// Jürgen

On 08/25/2016 03:15 PM, Louis de Forcrand wrote:
Yep, still 0 after )SIC.
I checked it with this function:

[1] ⎕IO←~⎕IO ◊ →1∇

And indeed ⎕IO goes back to its original value after )SIC.

Thank you. I should have put that in the original email.


On 25 Aug 2016, at 04:01, Christian Robert <address@hidden <mailto:address@hidden>> wrote:

After second though, you may have/had a point.

keep investigating.


On 2016-08-24 21:54, Louis de Forcrand wrote:
You are entirely right, I didn't do that when I reproduced it for the email. However I believe that I did check quad IO after )SIC the first time it happened and it was still 0.
Almost like the variables being localised are localised after execution?
I'll check again when I can.

Thanks for pointing that out.

On 25 Aug 2016, at 03:39, Christian Robert <address@hidden <mailto:address@hidden>> wrote:

try ⎕IO

*after*  )sic

the fact is that when a function is interruped, you see "by the last" interrupted function. Until you type )sic or )reset

my 2 cents, as usual, I may be wrong.


On 2016-08-24 21:09, Louis de Forcrand wrote:
   ∇Z←F N;⎕IO
[1] Z←⍎(N>1)⊃'N' 'N×F N-1'⊣⎕IO←0∇
   F 6
   f←{⍎(⍵>1)⊃'⍵' '⍵×f ⍵-1'⊣⎕IO←0;⎕IO}
   f 6
λ1[1]  λ←⍎(⍵>1)⊃'⍵' '⍵×f ⍵-1'⊣⎕IO←0;⎕IO
    ^                            ^
   f←{⍎(⍵>1)⊃'⍵' '⍵×⍙ ⍵-1'⊣⎕IO←0;⎕IO}
   f 6
   ⍵×⍙ ⍵-1

As is shown, system variables such as ⎕IO cannot be localised
in lambdas as they can be in del-fns.
The last example is there because I just thought the order of
execution was intriguing: it seems to show that the error with
local ⎕IO was signalled at the end (left) of the lambda. This
of course might be as it should.

In addition I was wondering if there is a way to refer to the
enclosing lambda / function anonymously, i.e. ∇ in Dyalog.
That is how I first entered the faulty symbol, and found this
potential bug.

Good luck,

reply via email to

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