[parenscript-devel] Package system, new reader, compilation interface changes, and more refactoring

Red Daly reddaly at gmail.com
Wed Jul 25 06:00:47 UTC 2007


Dear Parenscripters,

I have made some significant changes to the source code.  The impetus for
most of my changes was the creation of a package system for Parenscript.
This is a brief, rambling explanation of my changes to the code base and is
by no means a full documentation of new features.

The compilation interface is now contained in 'compilation-interface.lisp'.
The main functions for compiling Parenscript to Javascript are
COMPILE-SCRIPT, COMPILE-SCRIPT-FILE, and the macro SCRIPT.

The package system is very similar to Lisp's package system because it works
on the symbol level.  A script package has an associated lisp package that
it uses to intern all of that script package's symbols.  This way, the
parenscript package of any (lisp) symbol can be determined by looking at the
lisp package of any lisp symbol.  The Parenscript compiler mandates that
every symbol have an associated script package.  As a result, the compiler
now assigns semantic meaning to both a symbol's name and package--before
only the string name of a symbol had any bearing on the resultant code.

There are a few packages that come standard issue (see builtin-packages.lisp).
The macros provided by the Parenscript language are split into two package:
PARENSCRIPT and JAVASCRIPT.  JAVASCRIPT contains special forms that are
eventually translated directly to Javascript (e.g. defvar, lambda, with).
The PARENSCRIPT package is the package most users will use and contains the
rest of the special forms/macros described in the documentation (e.g.
macrolet, let, html).

There is now a Parenscript reader thanks to the BSD-licensed Sacla
project[SACLA].  Parenscript can use either the Lisp reader or the
Parenscript reader to read objects from source text.  Generally, Parenscript
embedded in Lisp will use the Lisp reader, and Parenscript in Parenscript
files (*.paren) will use the Parenscript reader.  (Though perhaps in the
future the Parenscript reader will be preferred.)  It is possible to use the
Lisp reader within the Parenscript reader with the reader macro
#L(lisp-form), which may be useful for some reason.  Parenscript does not
currently interfere with the Lisp reader by introducing reader macros. There
are only a few differences between the readers:
#  The Parenscript reader will not obey defined reader macros from the Lisp
reader
#  The Parenscript reader understands Parenscript package names as package
prefixes and
does NOT understand Lisp package names as package prefixes.
#  The Lisp reader does not understand Parenscript package names but does
understand Lisp package names as symbol prefixes.

I broke up source-model.lisp into js-source-model.lisp and
ps-source-model.lisp to correspond to the underlying Javascript and
Parenscript special forms.  I broke up parser.lisp into parser.lisp,
js-macrology, and ps-macrology: the macrology files define macros for
javascript and parenscript; parser.lisp contains the functionality for
parsing S-expressions into the objects defined in the source-model files.  I
moved js-html and js-css to the lib/ subdirectory; eventually these should
probably be members of other packages.

All tests currently pass and I am adding more tests.  More on the package
system later, after I have made use of it myself.


Happy hacking,
Red Daly

[SACLA] http://homepage1.nifty.com/bmonkey/lisp/sacla/index-en.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20070724/67b0bc4a/attachment.html>


More information about the parenscript-devel mailing list