3

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 the ride IDE. What I now want to do is to:

  1. Use the ride IDE 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!

EDIT: 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.

4

2 回答 2

4

目前,创建独立可执行文件(单个 .exe 文件)的能力仅存在于 Windows 上,但 Dyalog 正在努力使这种跨平台成为可能。但是,您可以非常接近。在我们开始之前,让我回答你最初的问题:

  1. 使用 Ride IDE 开发程序(我如何访问键绑定?)。

有几种方便的方法可以在 RIDE 之外输入字形,包括通过编辑器扩展和用于前缀和/或转换键输入的单独的系统范围方法。有关详细信息,请查看 APL Wiki 关于键入 glyphs的文章。

  1. 使用命令行参数从命令行运行程序(如何获取命令行参数?

⊢2⎕NQ#'GetCommandLineArgs'返回用于启动当前应用程序的命令和命令的参数。这适用于跨平台。Linux下在线试用!


您谈论的“实时图像”将是 APLers 所说的工作空间。一旦您的应用程序按照您的意愿工作,请输入将⎕LX(Latent eXpression) 变量设置为启动您的应用程序并在完成后关闭 APL 的语句,例如⎕LX←'myApp.Run ⋄ ⎕OFF'.

接下来,将您的应用程序保存为带有)save /tmp/myapp.

您现在应该可以使用dyalog -hello=world /tmp/myappetc 运行您的应用程序了。您当然可以将其放在 shell 脚本中以便于使用。

您将分发给客户的至少是工作区和运行时解释器,但您可能还想打包一些伴随文件/依赖项。但是,在从您的应用程序中赚钱之前,请查看 Dyalog 的价格和许可证

于 2020-03-16T10:36:34.967 回答
3

我就是这样做的(不是官方的 Dyalog 推荐):

使用 Ride IDE 开发程序(我如何访问键绑定?)。

RIDE 很酷(我有偏见),尤其是在您想以交互方式探索语言的开始时。

但在实践中,我更喜欢用这个插件用 Vim 编辑纯文本文件。它为键绑定提供了可配置的前缀键。我认为还有一种方法可以将 Vim 或 Emacs 配置为 RIDE 的外部编辑器 - 这样您就可以拥有闪亮的会话界面和熟悉的残酷高效的编辑器。

或者,对于您可以执行的键绑定:

setxkbmap -layout us,apl -option grp:win_switch

同时按下“Windows 键”和另一个键会在任何 X11 应用程序中插入一个 APL 字符 - 方便电子邮件、聊天等。

将我的程序保存到文件中。从命令行运行程序,

我把这个放在上面:

#!/bin/bash
(echo ∇M;tail -n+3 $0;echo -e '∇\nM\n⎕off')|dyalog -script;exit $?
⎕io←0⋄⎕ct←0⋄⎕pw←32767 ⍝ opinionated :)

chmod +x file.dyalog
./file.dyalog

使用命令行参数(如何获取命令行参数?)

这有点问题。有2⎕NQ#'GetCommandLineArgs'适用于 Windows 但我不知道适用于 Linux 的有效解决方案。

请参阅下面的评论和亚当的回答

分发我的程序,以便其他人可以使用它们。

任何你喜欢的方式 - github、gitlab、bitbucket、你自己的网站、鸽子等

“APL 会议”

这只是“REPL”的传统 APL 术语。

于 2020-03-16T10:05:15.577 回答