Nested namespaces in script get circular.

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Nested namespaces in script get circular.

Postby ArrayMac227 on Mon Jun 20, 2016 2:32 pm

Some code, (12.1):
      ⍪ns1←':Namespace test' ':Namespace test_a' 'x←''a''' ':endnamespace' ':namespace test_b' 'x←''b''' ':endnamespace' ':endnamespace'
:Namespace test
:Namespace test_a
x←'a'
:endnamespace
:namespace test_b
x←'b'
:endnamespace
:endnamespace
't161620c'⎕ns''
+t161620c.⎕fix ns1
#.t161620c.test
#.t161620c.test.⎕nl 9
test_a
test_b
#.t161620c.test.test_a.⎕nl 9 ⍝⍝ shows sibling namespace??
test_b

I use the Dyalog Explorer to look at the namespaces, and the 'circular' references cease. Given I cannot see the code for Explorer, I wonder how to work around this circularity.
ArrayMac227
 
Posts: 36
Joined: Sat Sep 12, 2015 1:40 pm

Re: Nested namespaces in script get circular.

Postby DanB|Dyalog on Tue Jun 21, 2016 4:01 pm

scripted namespaces (and classes) behave differently from unscripted namespaces.
In a scripted space the whole family (parents, children, grand-children, nephews, etc.) is visible to everyone. In unscripted nss not so.
This leads to circular references effectively.
To know if a spaces are siblings you need to look at their parent (##) and compare them. If they are = then they are siblings.
DanB|Dyalog
 


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest