[parenscript-devel] Added REPEAT clauses to PS loop
Vladimir Sedach
vsedach at gmail.com
Sat Aug 1 19:44:07 UTC 2009
Pushed. Thanks for the patch!
Vladimir
On Fri, Jul 31, 2009 at 2:23 PM, Daniel Gackle<danielgackle at gmail.com> wrote:
> I added the simple REPEAT clause that's supported by CL's LOOP to PS's
> pseudo-LOOP:
>
> (ps (loop repeat 3 do (alert "hi")))
>
> =>
>
> "for (var _js3691 = 0; _js3691 < 3; _js3691 += 1) {
> alert('hi');
> };"
>
> Daniel
>
>
> From 043a85a1f155068af509e05fd32ae2adcfb0f30f Mon Sep 17 00:00:00 2001
> From: Daniel Gackle <danielgackle at gmail.com>
> Date: Fri, 31 Jul 2009 14:20:15 -0600
> Subject: [PATCH] Added :REPEAT clauses to PS's LOOP.
>
> ---
> src/lib/ps-loop.lisp | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/src/lib/ps-loop.lisp b/src/lib/ps-loop.lisp
> index c7334fa..38ea78c 100644
> --- a/src/lib/ps-loop.lisp
> +++ b/src/lib/ps-loop.lisp
> @@ -9,7 +9,7 @@
> (defvar *loop-keywords*
> '(:for :do :when :unless :initially :finally :first-time :last-time
> :while :until
> :from :to :below :downto :above :by :in :across :on :index := :then
> :sum :collect
> - :count :minimize :maximize :into))
> + :count :minimize :maximize :into :repeat))
>
> (defun normalize-loop-keywords (args)
> (mapcar
> @@ -146,10 +146,15 @@
> ((:in :across) (for-in var))
> (:on (for-on var))
> (otherwise (error "FOR ~s ~s is not valid in PS-LOOP."
> var term)))))
> + (repeat-clause ()
> + (let ((index (ps-gensym)))
> + (setf terms (append `(:for ,index :from 0 :below
> ,(consume)) terms))
> + (clause)))
> (clause ()
> (let ((term (consume-atom)))
> (case term
> (:for (for-clause))
> + (:repeat (repeat-clause))
> (:while (push `(unless ,(consume) break) body))
> (:until (push `(when ,(consume) break) body))
> (:initially (push (consume-progn) initially))
> --
> 1.6.1
>
>
>
> _______________________________________________
> 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