Recently there was a post on the HN front page pointing to a GitHub repository containing an old (2019) version of the source for PyLucid (I don’t know who posted it). It generated a lot of interest in Lucid but unfortunately the 2019 version is crude and out of date and probably put people off.
I’m going to set things right by releasing an up to date version of PyLucid (Python-based Lucid) and up to date instructions on how to use it to run PyLucid programs. The source can be found at pyflang.com and this blog post is the instructions. (The source also has a brief README text file.)
Go to pyflang.com and download the file pylucid.1.2.zip and unzip it. There will appear three objects: a directory source, a command repl, and a file README.txt. This is all you need.
The source directory contains about 30 .py files (python code). You don’t have to know anything about them if all you want to do is run PyLucid programs.
The README.txt is basically a condensed version of this post.
The repl command launches the PyLucid Read-Evaluate-Print-Loop. You repeatedly enter one-character commands (possibly with arguments) and that’s how you interact with the interpreter. No UNIX commands other than repl itself.
Actually, “evaluate” is a bit misleading because you don’t enter PyLucid code on the command line. Instead you manipulate a program stored in an invisible buffer. The program stored in the buffer is called the current “import”, and when you first launch the repl it will inform you that the current import is “etothex”. It’s a simple program that calculates e using the power series for e**x with x=1.
To view (the program in) the buffer, use the “b” command. To edit it, use “v” (which launches vi). To evaluate (run) the program, use “e”.
The e command expects the buffer to contain a where clause, which consists of a subject (the value of the clause) and an (unordered) set of equations defining variables and functions. The variables denote two-dimensional datasets and the functions denote transformations (filters) on such datasets.
The e command evaluates the subject in the context of the definitions (the body) of the where clause. Note that the right hand sides of the definitions can be arbitrarily complex and may, for example, contain nested where clauses.
The e command evaluates the program and displays the results. However in PyLucid the value of a program is in general two dimensional – varying in both space and time. The interpreter uses the horizontal dimension for space, and the vertical dimension for time. Both dimensions are a priori infinite so it is necessary to limit the display in both directions.
The simplest way to do this is by defining the parameters (distinguished variables) “rows” and “columns”. For example, if the body includes the definitions “rows=10” and “columns=3” the display will be 10 (vertically) by 3 (horizontally), showing the values for time going from 0 to 9 and space going from 0 to 2.
More sophisticated effects can be achieved using the end-of-data and end-of-space special values.
The remaining commands are straightforward and are documented by the h[elp] command. However it may not be obvious how to create a new program, import it, and then remove it.
Suppose you want to create a program called “bleen”. The command “v bleen” will create it and “i bleen” will import it. At the moment there’s no way to remove a program but that will soon be fixed.
Finally, I should mention that there are two features currently not supported because bugs showed up during testing. One is nested iteration, the other is variable binding operators. I’m working on fixing them but in the meantime I thought it was more important to get PyLucid out there.These features and others will be available in future releases Real Soon Now.
These future releases will have new features, not just bug fixes. There will be more example programs. And I will be upgrading I/O so that in particular you can specify input and output prompts.