SL--Dependency Language

[image /static/bnf-sl.png]

[Github](https://github.com/equwal/sl) |
[Homepage](https://equwal.com/sl--dependency-language)

SL is a Domain Specific Language (ie. simple programming language) for
dealing with ambiguous dependency situations. It is more expressive than
the standard method in Common Lisp: the use of reader macros.

Examples

The only external macro is defsl. There is BNF below, though some
examples are in order.

Simple

This defines operator-arglist (in the current package) as
slynk:operator-arglist, unless slynk is unavailable, in which case
swank:operator-arglist is used.

` commonlisp
(defsl operator-arglist :fn :eq slynk swank)
`

The :fn shows that a FUNCTION is being defined, as opposed to a :sym
symbol; to define another namespace a list is required: (accessor-fn
boundp-fn)
. :eq denotes that the packages have the same name for this
function. For this simplest of examples, consider the reader macro
alternative.

``` commonlisp
#+(and slynk swank) (setf (symbol-function 'operator-arglist)

slynk:operator-arglist)

#+(and slynk (not swank)) (setf (symbol-function 'operator-arglist)

slynk:operator-arglist)

#+(and (not slynk) swank) (setf (symbol-function 'operator-arglist)

swank:operator-arglist)

#
```

Complex example

``` commonlisp
(defsl gensymmer (macro-function macro-function)

utils with-unique-names
alexandria with-gensyms)

```

To break this down:

  • gensymmer is now defined as utils:with-unique-names.

  • macro-function was used twice: once as a setfable place, and

once as a

predicate.

  • If the utils package does not exist, then sl::gensymmer is

defined as alexanrdia:with-gensyms.

  • to define different names for each package, they must be "qualified"

with the package name.

Install

Use ASDF to install. Usually this should work:

` bash
$ cd ~/common-lisp/
$ git clone git@github.com:equwal/sl.git
CL-USER> (asdf:load-system :sl)
`

BNF

``` example
(defsl <sl-name> <fnsym> <package spec>)
<package spec> ::= <eq>

<packages>

<eq> ::= :eq <preferences>
<fnsym> ::= :fn

:sym
<fnpair>

<fnpair> ::= (setfable-place bound-predicate)
<packages> ::= <package> <fn name> <more packages>
<package> ::= symbol
<fn name> ::= symbol
<preferences> ::= <package> <more packages>
<more packages> ::= &epsilon;

<package>
<package> <more packages>

```

Issues:

  • This is a new thing.

  • defsl is quite possibly the world's most unhygenic macro: don't

expect anything about evaluation order or number of evaluations to
be true.

in: articles

Spenser Truex

Contact
hacker emblem
| |