[parenscript-devel] ps-compile-file and eval-when, patch included

Vladimir Sedach vsedach at gmail.com
Wed Apr 29 06:22:57 UTC 2009


Makes sense. Pushed!

Vladimir

On Mon, Apr 27, 2009 at 3:06 PM, Red Daly <reddaly at gmail.com> wrote:
> 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.
>
> 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.
>
> A naiive file compiler for Parenscript looks like this:
>
> (defun ps-compile-file (source-file)
>       (with-open-file (input source-file :direction :input)
>         (let ((end-read-form '#:unique))
>           (flet ((read-form () (read input nil
> end-read-form)))
>                     (do ((form (read-form) (read-form))
>                          (forms nil))
>                         ((eql form
> end-read-form)
>                              (ps:ps* `(progn ,@(nreverse forms)))))))
>
> 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.
>
> 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:
>
> (defpsmacro in-package (package-designator)
>   `(eval-when (:compile-toplevel)
>        (setf cl:*package* (find-package ,package-designator))))
>
> Attached is a patch against the current git repository with this change and
> another bug fix.
>
> Best regards,
> Red
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
>




More information about the parenscript-devel mailing list