I have had Parenscript file compilation working in a local version of Parenscript for a long time, but this feature is still missing from the official Parenscript.  It seems like a logical feature to place into the main Parenscript project.<br>

<br>Parenscript is useful for creating large Javascript applications and where there are large software projects there is a need for files.  Some Parenscript interacts with Lisp code, but other Parenscript is written purely for the front-end.  This sort of code belongs in a standalone Parenscript file.<br>

<br>A naiive file compiler for Parenscript looks like this:<br><br>(defun ps-compile-file (source-file)<br>      (with-open-file (input source-file :direction :input)<br>        (let ((end-read-form '#:unique))<br>          (flet ((read-form () (read input nil end-read-form)))                                                                                                                                         <br>

                    (do ((form (read-form) (read-form))<br>                         (forms nil))<br>                        ((eql form end-read-form)                                                                                                               <br>

                             (ps:ps* `(progn ,@(nreverse forms)))))))<br><br>However, just as in Lisp, it is helpful to have a little more control when compiling files than just creating a PROGN  with the form and compiling as if it were any other code.  It is useful to have EVAL-WHEN forms to manipulate the reader and so on.  Therefore I have added the idea of top-level forms, including the EVAL-WHEN special form, to address this issue.<br>
<br>EVAL-WHEN in Parenscript is similar to EVAL-WHEN in lisp but it takes into account the fact that when compiling the relevant language is LISP, but when executing the relevant language is Parenscript.  An example of using EVAL-WHEN to define an IN-PACKAGE macro to manipulate the reader:<br>
<br>(defpsmacro in-package (package-designator)<br>  `(eval-when (:compile-toplevel)<br>       (setf cl:*package* (find-package ,package-designator))))<br><br>Attached is a patch against the current git repository with this change and another bug fix.<br>
<br>Best regards,<br>Red<br>