<br><br>A Parenscript package (or "script package" or simply "package," as opposed to a "Lisp package") has a few main properties: a name and list of nicknames, an primary associated Lisp package, a list of exported identifiers, and a collection of macros defined in the associated Lisp package. We must also introduce and formalize a two other concepts: Parenscript identifiers (analog of Lisp symbols), and a compilation environment.
<br><br>A Parenscript package is defined and exists in the context of a compilation environment. A compilation environment simply keeps track of compiler state; when any Parenscript code is compiled, a new compilation environment is created or an existing one is passed to the compiler. The environment is modified to reflect the lexical scope as forms are processed. Specifically, the compilation environment will consist of a stack of Parenscript identifiers (introduced by defun and defvar forms); a stack of macros and symbol macros; a list of defined script packages; and the current script package.
<br><br>An identifier in Parenscript is analogous to a Lisp symbol, but it only exists during compile time. An identifier has a string value and associated Parenscript package.<br><br>Now I will run through a simple example to demonstrate these new developments:
<br><br>Script packages are primarily defined using a Parenscript form analogous to the Lisp defpackage:<br><br>(defpackage friendly-script<br> (:use parenscript psos)<br> (:export hello-world)<br> (:lisp-package friendly)
<br> (:documentation "Scripts for issuing greetings."))<br><br>This introduces a new package into the compilation environment. We enter the package system after it is defined as in Lisp:<br><br>;; enter the friendly-script package
<br>; changes the current package in the compilation environment to :friendly-script<br>(in-package :friendly-script)<br><br>;; define the hello-world function, which we export<br>; adds friendly-script::hello-world to the identifier stack in the compilation env.
<br>(defun hello-world ()<br> (alert "hello world."))<br><br>;; enter the user package<br>; changes current package in compilation environment<br>(in-package :parenscript-user)<br><br>;; call the friendly-script's hello-world function
<br><br>friendlyScript_helloWorld();<br><br><br>In terms of implementation, the package system will introduce a few new classes (script-package, identifier, and compilation-environment); uproot existing parsing procedures and replant them around the package system; and add a semantic analysis phase into the compilation pipeline. I will fill in details and announce problems with the implementation as it moves forward.
<br><br>Anyhow, I look forward to comments on this proposal. Happy hacking!<br><br>Red<br>