Getting Names in Namespace in Order of Assignment

General APL language issues

Getting Names in Namespace in Order of Assignment

Postby paulmansour on Thu Aug 10, 2017 6:16 pm

⎕Nl returns things in alphabetical order.

Is there any way to retrieve the the names in a namespace in the order in which they were assigned?

If not, internally, how are the names in the symbol table stored? I would hazard a guess they are stored in some sort order related to assignment.
paulmansour
 
Posts: 240
Joined: Fri Oct 03, 2008 4:14 pm

Re: Getting Names in Namespace in Order of Assignment

Postby AndyS|Dyalog on Fri Aug 11, 2017 9:23 am

I'm afraid not .. the names are held in a binary tree, in the same order that Grade uses, so is different in Unicode and Classic editions.
User avatar
AndyS|Dyalog
 
Posts: 164
Joined: Tue May 12, 2009 6:06 pm

Re: Getting Names in Namespace in Order of Assignment

Postby paulmansour on Mon Aug 14, 2017 12:55 pm

Ok, thanks Andy.

I'm trying to impose order on the names in a namespace (for presentation, not computation). Order of assignment is usually how I want it. By hook and crook I can determine that order most of the time, but there are times when can't. I guess I will have to settle for explicitly assigning the ordering.
paulmansour
 
Posts: 240
Joined: Fri Oct 03, 2008 4:14 pm

Re: Getting Names in Namespace in Order of Assignment

Postby Morten|Dyalog on Tue Aug 15, 2017 7:18 am

There isn't a way to report this after the fact, but if you are sufficiently keen, in v16.0 you can roll your own solution using the extended Trigger mechanism which is designed for implementing various forms of data binding:

Code: Select all
      NS←⎕NS ''
      NS.⎕FX'LogAssignments arg' ':Implements Trigger *' '⎕←arg.Name'
      NS.life←42
life
User avatar
Morten|Dyalog
 
Posts: 300
Joined: Tue Sep 09, 2008 3:52 pm

Re: Getting Names in Namespace in Order of Assignment

Postby JoHo on Tue Aug 15, 2017 5:00 pm

Thank you for the hint. That is really cool!

That Seems to be mentioned now as "Global Triggers" in the most recent version of the Programming Reference Guide, dated Aug. 10th., to be found on the web site.
User avatar
JoHo
 
Posts: 15
Joined: Sat Nov 28, 2009 12:51 pm
Location: Austria, EU


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest