Shen-Language / shen-cl

Shen for Common Lisp (Unmaintained)
BSD 3-Clause "New" or "Revised" License
122 stars 11 forks source link

Trouble loading common lisp libraries #24

Closed Drainful closed 5 years ago

Drainful commented 5 years ago

I was wondering if there was an accepted way to load external common lisp libraries for use in Shen code through the "lisp." macro. I realize that the "lisp." macro allows the evaluation of lisp code, but the case restriction makes loading common lisp libraries troublesome. How do other people deal with this issue?

Thank you.

EDIT: I have opened a pull request with changes I believe will reduce this trouble. https://github.com/Shen-Language/shen-cl/pull/25

rkoeninger commented 5 years ago

I'm not sure if there's a workaround for this. Do you have a specific example where and how upper-casing became an issue?

Dealing with this might require changing how shen-cl works, an approach is described below.


Normally, the CL reader upper-cases all symbols as they are read. shen-cl uses case preservation to distinguish between CL and Shen functions and macros. For instance, IF is the CL conditional form and if is the Shen conditional form.

The lisp. form simply forces upper-case so a symbol that was prefixed with lisp. will match the name of a CL function and not a Shen one. But there would be nothing to stop you from naming a function in upper-case.

I've always thought that this is really awkward. It might be possible to use a :SHEN package for Shen code, and explicitly qualifying function calls not in a lisp. form, so you can use in-package to switch packages and it wouldn't break your Shen code. Don't know enough about CL packages to be sure if this would work.

Drainful commented 5 years ago

It’s funny you say that. I have edited my original issue to link to my pull request that implements that very feature. There are more details on the PR, but essentially all shen code (including the results of K Lambda translations) are entered into a new :SHEN package, and 3 new functions are exposed to the shen user to make use of this (as well as to avoid the reader case annoyance).

EDIT: there is still much to be done in terms of interoperation, for example creating an ASDF system for shen loadable in common lisp which would allow lisp to be the entry point of a shen+lisp program. After the package separation is made it would be ideal to implement k lambda as a readtable so that one could switch between languages as easily as changing the *readtable* variable.