command-line-argumentsexecutablesoftware-distributionapldyalog

Dyalog APL: How to write standalone files that can be executed?


I now know how to use the APL interpreter, but I'm quite confused about how to write APL into a file and then run the said file. I currently write Dyalog APL using RIDE. What I now want to do is to:

  1. Use the RIDE to develop programs (how else do I access the keybindings?).
  2. Save my program to a file.
  3. Run the program from the command line, with command line arguments (how do I take command-line arguments?)
  4. Distribute my program so others can use them.

Most of the documentation online refers to an "APL session", which makes me think that perhaps there's some Smalltalk-like thing going one, where one can only distribute the "live image" or some such. If that is the case, I have a different set of questions:

  1. How do I save and load these image files?
  2. How do I distribute image files?
  3. Can I execute such code from the command line, to take command-line arguments?

In general, I'm quite confused about how to write software in APL!

I'm on Ubuntu, and I'd like to target Linux in general. Windows/macOS support would be a plus, but I'm currently interested in Linux support.


Solution

  • For now, the ability to create a stand-alone executable (a single .exe file) only exists on Windows, but Dyalog is working on making this possible cross platform. However, you can get pretty close. Before we get to that, let me answer your initial questions:

    1. Use the ride IDE to develop programs (how else do I access the keybindings?).

    There are several convenient ways to enter the glyphs outside RIDE, both through editor extensions and separate system-wide methods for prefix and/or shifting key input. For details, have a look at APL Wiki's article on typing glyphs.

    1. Run the program from the command line, with command line arguments (how do I take command line arguments?)

    ⊢2⎕NQ#'GetCommandLineArgs' returns the command and the arguments to the command that was used to start the current application. This works cross-platform. Try it online under Linux!


    The "live image" you talk about would be what APLers call a workspace. Once your application is working as you want, enter set the ⎕LX (Latent eXpression) variable to a statement that starts your application and then closes APL when done, e.g. ⎕LX←'myApp.Run ⋄ ⎕OFF'.

    Next, save your application as a workspace with )save /tmp/myapp.

    You should now be able to run your application with dyalog -hello=world /tmp/myapp etc. You can of course put this in a shell script for ease of use.

    What you'll distribute to your customers would at a minimum be the workspace and the runtime interpreter, but you probably want to package some companion files/dependencies too. However, before making money off your application, look at Dyalog's prices and Licences.