[Openmcl-devel] goblock

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Sun Feb 24 05:52:25 PST 2013


Hi

I am currently using tagbody as follows:

(defun parse-tagblock (body tags)
  (labels ((%parse (e)
             (cond
               ((null e) nil)
               ((atom e) e)
               (t (cond
                    ((eq (car e) 'quote) e)
                    ((and (symbolp (car e))
                          (string= (symbol-name (car e)) "TAGBLOCK"))
                     `(block ,(cadr e)
                        (tagbody ,@(parse-tagblock
                                    (cddr e)
                                    (append (loop for a in (cddr e)
                                               when (symbolp a) collect a)
                                            tags)))))
                    ((and (symbolp (car e))
                          (string= (symbol-name (car e)) "GOTO"))
                     (let ((tag (%parse (cadr e))))
                       `(case ,tag
                          ,@(loop for x in tags
                               collect `(,x (go ,x)))
                          (t (error (format nil "Can't Go to ~S" ,tag))))))
                    (t `(,(%parse (car e)) ,@(%parse (cdr e)))))))))

   (%parse body)))

(defmacro tagblock (name &rest args)
  `(block ,name
     (tagbody ,@(parse-tagblock
                 args
                 (loop for a in args
                    when (symbolp a) collect a)))))




tagblock works exactly like tagbody with the additions goto and block; this
works even if the tagblocks are nested

The issue is that the goto is basically transformed to a case instruction
and this can be improved by doing an indirect jump as in assembler; for
this reason I explored the possibility to implement this using lap-functions
but unfortunately I do not have enough knwowledge to tackle this for now.

As a first step I implemented the tagblock using funcall and now I am
hoping to find a way to rewrite it using lap-functions and replace funcalls
by an indirect jump

Where can I find a tutorial about lap-functions, I tried to read
compiler/.../nx*.lisp staff but found it difficult to grasp
without any previous knowledge

Kind regards
Taoufik




On Sun, Feb 24, 2013 at 12:35 PM, Pascal J. Bourguignon <
pjb at informatimago.com> wrote:

> Taoufik Dachraoui <dachraoui.taoufik at gmail.com> writes:
>
> > Hi
> >
> > I needed to have a computed GO in one of my developments
> > I could not use tagbody
>
> Why can't you use tagbody?
>
>
> https://groups.google.com/forum/?fromgroups=#!msg/comp.lang.lisp/wr3ekiLN8sI/NjVkbNRCVMgJ
>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
> A bad day in () is better than a good day in {}.
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130224/533f87d1/attachment.htm>


More information about the Openmcl-devel mailing list