VGET

General discussions on potential enhancements to the APL+Win system.

VGET

Postby Ajay Askoolum » October 22nd, 2018, 1:16 am

I'd like the scope of []vget extended so that it can return the value of built-up expressions in order to avoid execute in code.

Code: Select all
      var←(,['']⊂[2]last_name),⊂[2]first_name     
      ⍴var
1000 2
      first←,1
      ⎕vget 'var[;first]'
DOMAIN ERROR
At present, I can execute the expression - would like to avoid this and use []vget instead
Code: Select all
      ⍴⍎ 'var[;first]'
1000 1
Generalize VGET to mean value get rather than variable get.
Ajay Askoolum
 
Posts: 743
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: VGET

Postby Davin Church » October 22nd, 2018, 1:33 am

Personally, I always wanted something like VGET that could return values at any level of the )SI, not just local and global. It seems to me that some version (perhaps APL2?) had a dyadic form of {execute} that took a left argument indicating the depth of the stack at which the expression was executed. Of course, that has complications if you try to execute a branch at a lower level of stack, and things like that. And {execute} is what you're trying to avoid with VGET, but perhaps you see my line of thinking.
Davin Church
 
Posts: 543
Joined: February 24th, 2007, 1:46 am

Re: VGET

Postby brent hildebrand » October 22nd, 2018, 2:01 am

While on the topic of []VGET: The syntax is:
[]VGET 'varname' [default value]

the [default value] is executed no matter if varname is defined or not. It would seem [default value] be ignored if varname is defined. Here is an extreme example.
Code: Select all
      ⎕def 'ret←DefaultValue' '⎕dl 3 ⍝ simulate long calculation' 'ret←⎕ai'
DefaultValue

      ⎕vget 'var' DefaultValue
3.001
1 73.571 0 0
      var←1 2 3
      ⎕vget 'var' DefaultValue
3
1 2 3
brent hildebrand
 
Posts: 503
Joined: February 12th, 2007, 5:53 pm
Location: Loma Linda, CA

Re: VGET

Postby Ajay Askoolum » October 22nd, 2018, 3:32 am

My scenario is quite simple.

Imagine that you have just read an Excel worksheet into an APL variable using COM. The Excel source had column names in the first row. If follows that the APL variable has rows in the first row also.

I am attempting to index the APL variable by the name of the column.

(var[1;]) {comes from} {iota} {shape} var[1;]

If var[1;] had Name Gender Salary, I should get values out using var[;,Gender] etc.

[]VGET should evaluate an expression and if that fails, it should return the default value. Right now, it appears to look up the symbol table to figure out what to return.

(I don't have APL on this PC, hence the names of symbols and not the symbols themselves.)

PS: I looked at []eval - frankly, given the way it works, its purpose is lost on me.
Ajay Askoolum
 
Posts: 743
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: VGET

Postby Davin Church » October 22nd, 2018, 11:33 am

Ajay Askoolum wrote:PS: I looked at []eval - frankly, given the way it works, its purpose is lost on me.

IIRC, []EVAL was entirely about allowing extremely long arguments.
Davin Church
 
Posts: 543
Joined: February 24th, 2007, 1:46 am


Return to APL+Win Wish-List

Who is online

Users browsing this forum: No registered users and 1 guest

cron