Why does the starting namespace for ⍵⍵ change based on ⍺⍺?
12 posts
• Page 1 of 2 • 1, 2
Why does the starting namespace for ⍵⍵ change based on ⍺⍺?
Any thoughts on why the starting namespace for a (dfn) function used as the right operand of an operator shifts to the operator's own namespace depending on whether the left operand is a function or an array? (Please note: this is a simplified case to demonstrate the problem. The actual code of interest is more complex, using ⍺⍺, ⍵, etc.)
Version: 18.0.38756, Platform: Mac-64, Edition: Unicode/64, Date: Jul 16 2020 at 01:08:20
'Home namespace',⎕THISForcing ⍵⍵ to be in the target namespace does however work (however inelegant):
Home namespace #
'ns' ⎕NS ''
ns.do←{⍵⍵ ⍵}
var←'success'
{1} ns.do {⎕←'This is',⎕THIS ⋄ var}⊣1 ⍝ ⍺⍺ is a fn {1}.
This is # ⍝ ⍵⍵'s namespace is as expected.
success
(1⍨) ns.do {⎕←'This is',⎕THIS ⋄ var}⊣1 ⍝ ⍺⍺ is a fn (1⍨). Ditto
This is #
success
1 ns.do {⎕←'This is',⎕THIS ⋄ var}⊣1 ⍝ ⍺⍺ is a scalar (1).
This is #.ns ⍝ ⍵⍵'s namespace shifts to ns
VALUE ERROR: Undefined name: var ⍝ <var> is ONLY defined in #, not ns
1 ns.do {⎕←'This is',⎕THIS ⋄ var}⊣1
1 ns.do #.{⎕←'This is',⎕THIS ⋄ var}⊣1"Curiouser and curiouser!", cried Alice!
This is #
success
Version: 18.0.38756, Platform: Mac-64, Edition: Unicode/64, Date: Jul 16 2020 at 01:08:20
- petermsiegel
- Posts: 143
- Joined: Thu Nov 11, 2010 11:04 pm
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
Does the same happen with most recent version for Mac64 18.0.39263, 2020-10-02 ?
HTH
/J
HTH
/J
-
JoHo - Posts: 37
- Joined: Sat Nov 28, 2009 12:51 pm
- Location: Austria, EU
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
I don't think I have access to that version (latest I see is the one I posted). Happy to try the newer version if someone can point me to it.
- petermsiegel
- Posts: 143
- Joined: Thu Nov 11, 2010 11:04 pm
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
Sorry, it seems that is a version listed for DSS members only.
-
JoHo - Posts: 37
- Joined: Sat Nov 28, 2009 12:51 pm
- Location: Austria, EU
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
At least I can answer my own question,
that with the latest v18.0 under Windows 32bit, your example shows the same behaviour.
So I think, this is a case for Support.
that with the latest v18.0 under Windows 32bit, your example shows the same behaviour.
So I think, this is a case for Support.
'.' ⎕wg 'aplversion'
Windows 18.0.39262.0 W Development
'Home namespace',⎕THIS
Home namespace #
'ns'⎕NS''
ns.do←{⍵⍵ ⍵}
ns.var←'var_value_ns_'
var←'success'
{1}ns.do{⎕←'This is',⎕THIS ⋄ var}⊣1 ⍝ ⍺⍺ is a fn {1}.
This is #
success
(1⍨)ns.do{⎕←'This is',⎕THIS ⋄ var}⊣1 ⍝ ⍺⍺ is a fn (1⍨). Ditto
This is #
success
1 ns.do{⎕←'This is',⎕THIS ⋄ var}⊣1 ⍝ ⍺⍺ is a scalar (1).
This is #.ns
var_value_ns_
1 ns.do{⎕←'This is',⎕THIS ⋄ var}1 ⍝ ⍺⍺ is a scalar (1).
This is #.ns
var_value_ns_
-
JoHo - Posts: 37
- Joined: Sat Nov 28, 2009 12:51 pm
- Location: Austria, EU
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
Hi Peter and JoHo,
I can see the behaviour in our latest development code (what will probably be called 19.0) as well and will ask my colleagues about it.
Regards,
Vince
I can see the behaviour in our latest development code (what will probably be called 19.0) as well and will ask my colleagues about it.
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
This looks very much like a new incarnation of "bug[17]". Was it ever fixed?
then after my repro
John Scholes - on 5 June 2018 - wrote:We have a known bug [17] - see repro below - but I'm keen to check in case the one to which our refer is different.
Cheers, John.
bug17←{ ⍝ should return 1
oper←{
⍺⍺ ⍵
}
VAR←'outer'
{
VAR←'inner'
f1←{
VAR≡'inner':f2 ⍵ ⍝ OK so far
0 ⍝ fails
}
f2←{
VAR≡'inner':1 ⍝ OK
0 ⍝ fails
}
⍵:⊢f1 oper ⍵ ⍝ stack call
f1 oper ⍵ ⍝ tail call
}⍵
}
bug17 0 ⍝ fails with tail call
0
bug17 1 ⍝ succeeds with stack call in V13.1 (fails in V≥13.2)
1
then after my repro
Yup, it's bug[17] - thanks.
Maria Wells reported this bug may years ago. Unfortunately, the fix requires a pretty major re-vamp of the way dfns lexical scoping is implemented and we have never quite had the time to devote to it. Plus, I now have only about a third of the number of grey cells I had when I first implemented dfns, so I'd need a young, brainy person to do the heavy lifting. Rest assured "it's still on the list".
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
Hi Peter,
I have logged this Dop issue as 18570.
Regards,
Vince
I have logged this Dop issue as 18570.
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
Re: Why does the starting namespace for ⍵⍵ change based on ⍺
Hello Phil,
IMO it is different,
with Peter's reproducible the globlal context of a fn inside an d-operator changed, depending of the data-type of different left operands to that d-op.
With Bug17 it seems, it was an intrinsic change of context depending on two different obscure calling methods of the very same code. Bug17 seems to be fixed.
IMO it is different,
with Peter's reproducible the globlal context of a fn inside an d-operator changed, depending of the data-type of different left operands to that d-op.
With Bug17 it seems, it was an intrinsic change of context depending on two different obscure calling methods of the very same code. Bug17 seems to be fixed.
⎕vr 'bug17'
∇ bug17←{ ⍝ should return 1
[1] oper←{
[2] ⍺⍺ ⍵
[3] }
[4] VAR←'outer'
[5] {
[6] VAR←'inner'
[7] f1←{
[8] VAR≡'inner':f2 ⍵ ⍝ OK so far
[9] 0 ⍝ fails
[10] }
[11] f2←{
[12] VAR≡'inner':1 ⍝ OK
[13] 0 ⍝ fails
[14] }
[15] ⍵:⊢f1 oper ⍵ ⍝ stack call
[16] f1 oper ⍵ ⍝ tail call
[17] }⍵
[18] }
∇
'.' ⎕wg 'aplversion'
Windows 18.0.39262.0 W Development
bug17 0
1
bug17 1
1
-
JoHo - Posts: 37
- Joined: Sat Nov 28, 2009 12:51 pm
- Location: Austria, EU
12 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group