I have probably forgotten something, but...

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 !
Post Reply
crishog
Posts: 61
Joined: Mon Jan 25, 2010 9:52 am

I have probably forgotten something, but...

Post by crishog »

Take

r←'Resources'#.⎕NS''
Resources.x←1
r.y←1
SYNTAX ERROR
r.y←1

r
#.Resources

Just wondering why I get the syntax error
User avatar
kai
Posts: 141
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

Re: I have probably forgotten something, but...

Post by kai »

You intuitively assumed that
      r←'Resources'#.⎕NS''

assigns a reference to "r", but it's rather a name.

Instead
      r←⍎'Resources'#.⎕NS''

does the trick.

Or you do it this way:

      Resources←⎕ns''
Resources.x←1
Resources.y←1
crishog
Posts: 61
Joined: Mon Jan 25, 2010 9:52 am

Re: I have probably forgotten something, but...

Post by crishog »

Whereas monadic quad NS does return the anonymous namespace. The result is not as consistent as I thought

I meant to type

Resources <- []NS ''

Sorry no APL keyboard at the moment
User avatar
kai
Posts: 141
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

Re: I have probably forgotten something, but...

Post by kai »

Yes, it's not consistent, but there's a reason why:

1. When ⎕NS was introduced, references weren't yet available in Dyalog.

2. With anonymous namespaces on the other hand there is no name, so it can only return a reference.
Post Reply