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 !

I have probably forgotten something, but...

Postby crishog on Sat Jul 30, 2022 1:42 pm

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

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

Postby kai on Sat Jul 30, 2022 8:13 pm

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
User avatar
kai
 
Posts: 137
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

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

Postby crishog on Sun Jul 31, 2022 9:46 pm

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

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

Postby kai on Mon Aug 01, 2022 4:16 pm

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.
User avatar
kai
 
Posts: 137
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest