Archived
1
Fork 0
A toy sandbox-friendly lisp
This repository has been archived on 2026-03-10. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Python 98.2%
  • HTML 0.9%
  • Makefile 0.9%
Find a file
2020-05-21 00:08:27 -04:00
.circleci Circle config 2017-11-08 04:13:30 -05:00
.hypothesis/examples Renamed defmacro to define-macro, we're not heathens. 2017-11-15 00:48:19 -05:00
_templates Massively expanded the reference section. 2017-12-06 04:21:29 -05:00
actinide Some basic iteration primitives. 2017-12-10 23:48:55 -05:00
bin REPL now has a nice prompt, and simple readline support. 2017-11-15 03:21:01 -05:00
docs Weaken the language around security promises to be more in line with my ability to responsibly support this code. 2020-05-21 00:08:27 -04:00
tests Renamed defmacro to define-macro, we're not heathens. 2017-11-15 00:48:19 -05:00
.gitignore Sphinx setup 2017-11-18 21:15:06 -05:00
conf.py Massively expanded the reference section. 2017-12-06 04:21:29 -05:00
index.rst Write up documentation for the built-in functions and macros. 2017-12-10 23:11:12 -05:00
LICENSE Add license file 2019-01-06 15:18:19 -05:00
Makefile Sphinx setup 2017-11-18 21:15:06 -05:00
README.rst Weaken the language around security promises to be more in line with my ability to responsibly support this code. 2020-05-21 00:08:27 -04:00
requirements-docs.txt Upgrade docs requirements. 2019-09-26 00:27:54 -04:00
setup.py Bump minor version. 2017-12-05 01:25:00 -05:00

########
Actinide
########

.. image:: https://circleci.com/gh/ojacobson/actinide.svg?style=svg
    :target: https://circleci.com/gh/ojacobson/actinide

.. image:: https://readthedocs.org/projects/pip/badge/
    :target: https://https://actinide.readthedocs.io/


**An embeddable lisp for Python applications.**

I had `an application`_ in which the ability to extend the application from
within, safely, was valuable. None of the languages I reviewed met my criteria:

.. _an application: https://github.com/ojacobson/cadastre/

* `Lua`_ provides `primitives`_ which can be used to interact with the host
  environment, but no facility that guarantees that these tools are
  unavailable. I needed to be able to accept programs from hostile users
  without worrying that they'd overwrite files on the OS.

* `Python itself`_ has the same problem, but more so. Techniques for importing
  arbitrary code even in constrained Python execution environments are well
  known and, as far as I know, unfixable.

* `V8`_ is an attractive option, as it was originally built to evaluate
  Javascript functions in the browser. OS interaction is provided by the
  execution environment, rather than as part of the language's standard
  library. Leaving that out is easy.

  However, the problem space I was working in strongly pushed against using a
  language with no integers and with complex semicolon rules.

.. _Lua: https://www.lua.org
.. _primitives: https://www.lua.org/manual/5.3/manual.html#pdf-os.exit
.. _Python itself: https://python.org/
.. _V8: https://developers.google.com/v8/

So I wrote my own. This is that language.

This is a tiny lisp, along the lines of Peter Norvig's `lispy`_, designed to be
embedded within Python programs. It provides minimal safety features, but the
restricted set of builtins ensures that Actinide programs **probably** cannot
gain access to the outside context of the program. The worst they can do is
waste CPU time, fill up RAM, and drain your battery.

.. _lispy: http://norvig.com/lispy.html

************
Requirements
************

Actinide requires Python 3.6 or later.

Building the documentation requires Sphinx, and should be done in a Python virtual environment:

.. code-block:: bash

    $ python3.6 -m venv .venv
    $ source .venv/bin/activate
    $ pip install -r requirements-docs.txt
    $ make html
    $ open _build/html/index.html # or any other command to launch a browser

The documentation is also available online at https://actinide.readthedocs.io.

************
Installation
************

.. code-block:: bash

    $ pip install actinide
    $ pip freeze > requirements.txt

Or, if you prefer, add ``actinide`` to your application's ``Pipfile`` or
``setup.py``.

*****************
Freestanding REPL
*****************

The Actinide interpreter can be started interactively using the
``actinide-repl`` command. In this mode, Actinide forms can be entered
interactively. The REPL will immediately evaluate each top-level form, then
print the result of that evaluation. The environment is persisted from form to
form, to allow interactive definitions.

To exit the REPL, type an end-of-file (Ctrl-D on most OSes, Ctrl-Z on Windows).