Is there a system variable to know the name of the current function, if any ?

Is there a system variable to know the name of the current function, if any ?

PostPosted by FDA OSInet » Fri Sep 15, 2017 5:01 pm

OK, I guess everybody will answer me : "Read its f*** header !".

However let us imagine a complicated APL function which in SOME cases has to call itself recursively. Now, the name of the function has to be written in the header AND every time we call it. If we change the name of the function, we have to change it everywhere. Isn't it a bi Java-ish ? If we had a system variable like ⎕CFN (for "current function name", or whatever else, we could juste execute it by ⍎⎕CFN and not worry about future name changes. Bash allows it. Why would not NARS2000 ? (but perhaps it exists. I am not sure).
FDA OSInet
 
Posts: 29
Joined: Sun Aug 30, 2015 5:07 am

Re: Is there a system variable to know the name of the current function, if any ?

PostPosted by forummaster » Mon Sep 18, 2017 7:20 pm

FDA OSInet wrote:OK, I guess everybody will answer me : "Read its f*** header !".

However let us imagine a complicated APL function which in SOME cases has to call itself recursively. Now, the name of the function has to be written in the header AND every time we call it. If we change the name of the function, we have to change it everywhere. Isn't it a bi Java-ish ? If we had a system variable like ⎕CFN (for "current function name", or whatever else, we could juste execute it by ⍎⎕CFN and not worry about future name changes. Bash allows it. Why would not NARS2000 ? (but perhaps it exists. I am not sure).
There is already a mechanism to refer to the name of the current function: ∇

This feature is hidden in documented in

http://wiki.nars2000.org/index.php/User ... /Operators

as follows:

Within a recursive user-defined function, a del symbol (∇) refers to the user-defined function without having to name it. For example,

∇ Z←fibonacci R
[1] :if R≤1 ⋄ Z←1 ⋄ →0 ⋄ :end
[2] Z←(∇R-1) + ∇R-2


Within a recursive user-defined operator, a del symbol (∇) refers to the derived function of the user-defined operator with the current operands bound to the operator name without having to name it. For example, with a monadic operator whose header looks like

∇ Z←(LO mop) R

a del symbol in the body of the operator is a shorthand for (LO mop), and for a dyadic operator whose header looks like

∇ Z←(LO dop RO) R

a del in the body of the operator is a shorthand for (LO dop RO).

Within a recursive user-defined operator, two del symbols (∇∇) refer to the operator name with no bound operands. For example, in the monadic operator case above in the body of the operator, ∇∇ refers to mop, and in the dyadic operator case above, ∇∇ refers to dop, and in both cases without having to know the actual name.
forummaster
 
Posts: 567
Joined: Wed Jan 23, 2013 1:00 pm

Re: Is there a system variable to know the name of the current function, if any ?

PostPosted by FDA OSInet » Mon Oct 02, 2017 5:32 pm

Thanks a lot ! ;)
FDA OSInet
 
Posts: 29
Joined: Sun Aug 30, 2015 5:07 am


Return to New System Functions

Who is online

Users browsing this forum: No registered users and 1 guest

cron