bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] assignment to many variables


From: Juergen Sauermann
Subject: Re: [Bug-apl] assignment to many variables
Date: Thu, 11 Feb 2016 12:30:53 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hi Alex,

in APL you do not pass variables to a function, you pass values.
In your example I believe you could (conceptually) something like this:

fun (a b c ...)←1 (2 3) 4 ...

Since you pass values and not variables, the vector assignment above is not needed
and you could pass the value directly (the advantage or maybe disadvantage of the
vector assignment above is that an incorrect number of arguments will be detected
before fun is called, and that the number of items is made explicit):

fun 1 (2 3) 4 ...

inside the function, you then simply "undo" the above "assignment":

∇fun B
(a b c ...) ← B
...

/// Jürgen


On 02/11/2016 03:27 AM, address@hidden wrote:
Hi Bug-APL,
In the context of passing many variables to a function,
I am worried that I am going to forget the parenthesis, since its a really subtle thing:
      (a b)←1 2
      a
1
      b
2
      a b←1 2
 1  1 2
      a
1
      b
1 2


Also here, I find binding strength a bit misleading, since the correctly parenthesis'd version correctly throws an error, but the incorrect version passes an 'unanticipated' value if a is previously defined. If 'a' does not exist then an error is also correctly thrown:
      a b←1 2 3
 1  1 2 3
      a
1
      b
1 2 3
 
      ⎕ex'a'
1
      a b←1 2 3
VALUE ERROR
      a b←1 2 3
      ^


I don't think any change is necessary in GNU APL.  I'm just wondering if there are different approaches to passing many variables to a function. Any suggestions?

-Alex


reply via email to

[Prev in Thread] Current Thread [Next in Thread]