user defined commands written in APL

Let it all hang out

user defined commands written in APL

PostPosted by drab » Wed Mar 08, 2017 4:15 pm

Having user defined commands would be HUGE. I can't think of any other single feature that would be as powerful as this. I would use this all the time for SO many things.

This feature has already been described in another thread like this ...

"The way to do this is for me to implement ] user commands (as opposed to ) system commands) which reads an APL function (which you write) from an external file whose name follows the right bracket and executes the function when you invoke the comnand. This will give you access to a great many features without having to wait for your request to bubble up to the top of my list."


Here's are some of my blue sky wishes ...

The way to invoke one is

] command arguments

where "command" is the name of a function in a special saved workspace of command functions. Maybe the name of that workspace could be in a user preference.

All the arguments specified on the invoking bracket line (if any) are supplied to the command function as a single character vector, which may be empty.

The command function would run anonymously, without any possibility of name conflict.

The command function would behave similarly to a locked function.

The command function would have access to everything in the current workspace.

The command function would be able to do anything at all, including display output, and perform file I/O, or even call a function in the current workspace.

After the function completes, it would disappear, and leave no trace that it was ever there, unless it intentionally created global objects.


There are some open design questions ...

What happens if the command function hits an error? Maybe just report a COMMAND ERROR.

Could the command function call another function from the special saved workspace of command functions? It would probably be a lot simpler, but not much less powerful, to just not allow that (at least for now).
drab
 
Posts: 295
Joined: Thu Oct 09, 2014 6:23 am

Re: user defined commands written in APL

PostPosted by drab » Thu Mar 09, 2017 10:37 am

A corollary of running anonymously is that if a command function does ⎕nl 3, it will not find itself in the list.
drab
 
Posts: 295
Joined: Thu Oct 09, 2014 6:23 am

Re: user defined commands written in APL

PostPosted by forummaster » Fri Mar 10, 2017 7:51 am

drab wrote:A corollary of running anonymously is that if a command function does ⎕nl 3, it will not find itself in the list.

This is what Namespaces provide. There is already mechanism to do this via ##.name; however, I don't have a way for the end user to create a Namespace, so its usage is limited to certain Magic Functions for which I have created a separate Hash and Symbol Table . The System Level syntax of ##.var looks up to the next level of Namespace for the name reference to var and ##.fcn executes the function in the next level up Namespace. In a Magic Function, this allows it to access a value upstream as well as retrieve (say) the ⎕CR of a function without conflicting with the local names in the Magic Function.

Note that Namespaces are not the same as function levels. They are a separate linked list in a separate chain.
forummaster
 
Posts: 554
Joined: Wed Jan 23, 2013 1:00 pm

Re: user defined commands written in APL

PostPosted by drab » Fri Mar 10, 2017 11:45 am

Yes, I thought that hard stuff was already in there.

I hope the remaining stuff needed for user defined commands is easy compared to that.
drab
 
Posts: 295
Joined: Thu Oct 09, 2014 6:23 am


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron