Page 1 of 1

Wish-list: execute changes

Posted: Fri Nov 04, 2011 12:42 pm
by Peter Merritt
As Christmas is approaching, I thought I'd send Santa's IT support a couple of requests...

1. A new ⎕SET (or something) to replace currently awful WS constructs so assigning a known value to an unknown name goes from:
value←911 'Yes' 'No'
⍎varname,'←value'


to

varname ⎕SET value

2. A more controlled 'execute' - perhaps the old IBM ⎕EA?

(For those born in the last quarter of the 20thC, IBMs' fn took a chr vec as both left and right args. The fn would execute the right arg first until an internal trap which, if it failed, then triggered the left arg instead.)

Re: Wish-list: execute changes

Posted: Fri Nov 04, 2011 2:27 pm
by Dick Bowman
As for your first suggestion, two thoughts come to mind...

0⊃ Have you tried writing a defined function equivalent to your ⎕SET? It would seem relatively easy, assuming you bury it in a utility namespace the only snag I can see is whether the variable name is "relative" (assign in the calling namespace) or "absolute" (you've given the fully qualified name). Distinguishing these cases looks like it might be a task for ⍠ - if its domain would extend beyond ⎕R and ⎕S.

1⊃ Maybe there's a perverse advantage to readability in what we have now, in so far as firstly (or zerothly) we can read it as an idiom (even though the interpreter might not), and secondly (or onethly) having the '←' in the line makes it clear to the reader that the line is changing a value. I value APL's explicit cause-and-effect quite highly - never like losing it.

Re: Wish-list: execute changes

Posted: Sun Nov 06, 2011 5:11 pm
by Phil Last
Mostly agree with Dick. The location, both of the utility function and the destination for the array, can be a snag. The want of a recognisable "idiom" means I currently favour:
      names{⍎'(',⍺,')←⍵'}values        ⍝ for in-situ naming
names space.{⍎'(',⍺,')←⍵'}values ⍝ for a known namespace

The second is usually the necessary choice. The parentheses allow ⍺ to be a list.
Putting it in a utility not only hides the assignment but forces the decision as to the syntax:
      space names is values
names is space values
&c.

where "is" is the utility name that could be any name but unfortunately not "←".
Personally I'd hate to have yet another ⎕fn but could live with or might even welcome some new syntax such as:
      names←:values

that of course wouldn't have to be yet another use of the already heavily used colon but unicode offers a few million other choices. Didn't Adrian suggest a stile overstruck with left-arrow for something like this?
Ken came up with:
      (names)←values
where names is a simple character name or a boxed array of them but APL2 and subsequently Dyalog have precluded this usage with the parentheses around strand assignment used above.

Re: Wish-list: execute changes

Posted: Tue Nov 08, 2011 1:27 pm
by kai
Peter:

Regarding your first wish I would like to know first why you think you need this. It's not obvious to me.

Regarding the second wish: what exactly is wrong with

EA←{0::⍎⍺ ⋄ ⍎⍵}

?