From: Nils Goesche
Subject: Re: ····@
Date: 
Message-ID: <lku1ikw1mi.fsf@cartan.de>
Pascal Costanza <········@web.de> writes:

> I have written the following macro.

[snip]

> Its purpose is to allow returning values from somewhere in the
> middle of a function.
> 
> So for example you can do the following things.
> 
>  > (····@
>      (format t @"Hello, World!"))
> Hello, World!
> "Hello, World!"
> 
> (defmethod test ()
>    (format t "Hello, World!"))
> 
> (defmethod test :around ()
>    (format t "around: ")
>    @(call-next-method)
>    (format t " :around"))
> 
>  > (test)
> around: Hello, World! :around
> NIL
> 
> The purpose of this posting is to check whether I have got this
> macro right. It seems to work well - but is there anything I might
> have overlooked? Any comments?

What I don't like about it:

(····@ 3 @2 (+ 2 3))

gives an error, and

(····@ 32 @(+ 2 3) (print '(foo @ bar)))

doesn't print (FOO @ BAR) as it (IMHO) should.  And the following
doesn't work, either:

(····@ (flet ((foo (x)
                (····@
                 (print 'foo)
                 @(+ x 2)
                 (print 'foo-out))))
         (format t "(FOO 40) is ~D" (foo 40)))
       @(+ 5 7)
       18)

Regards,
-- 
Nils G�sche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0

From: Pascal Costanza
Subject: Re: ····@
Date: 
Message-ID: <3DD3E21B.3010807@web.de>
Nils Goesche wrote:
> Pascal Costanza <········@web.de> writes:
> 
> 
>>I have written the following macro.
> 
> 
> [snip]
> 
> 
>>Its purpose is to allow returning values from somewhere in the
>>middle of a function.
>>

> 
> 
> What I don't like about it:

[several hard cases]

Thanks a lot for those. Here is a new version which should cover them.

(defun ·····@ (list varsym)
   (unless (consp list) (return-from ·····@ list))

   (let ((carl (car list))
         (carln nil))

     (case carl
       ((quote ····@) list)

       (@ `((progn
              (setf ,varsym
                    (multiple-value-list
                     ,(·····@ (cadr list) varsym)))
              (values-list ,varsym))
            ,@(·····@ (cddr list) varsym)))

       (otherwise
        (if (and (symbolp carl)
                 (setq carln (symbol-name carl))
                 (eq (aref carln 0) ··@))
            (progn
              (assert (not (eq (aref carln 1) #\#)) ()
                "Reader macro immediately after @ in ····@.")
              `((progn
                  (setf ,varsym
                        (multiple-value-list
                         ,(read-from-string (subseq carln 1))))
                  (values-list ,varsym))
                ,@(·····@ (cdr list) varsym)))
          `(,(·····@ carl varsym)
            ,@(·····@ (cdr list) varsym)))))))

(defmacro ····@ (&body body)
   (let ((result (gensym)))
     `(let ((,result nil))
        ,@(·····@ body result)
        (values-list ,result))))


Anything else? ;)

Pascal

-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)
From: Marcus Breiing
Subject: Re: ····@
Date: 
Message-ID: <ouJsn8Xc2pNvlrETnsvtuW@breiing.com>
Pascal Costanza <········@web.de> wrote:

> Anything else? ;)

Sure ;-)

What do you think 

(····@ 
 (let ((@ 2)) 
   @)) 

should return (once you get rid of the macroexpansion-time errors)?

Hey, when you're done with ····@, don't forget to abstract-out the
more interesting parts.  Maybe call it WALKER?


-- 
Marcus Breiing
···················@breiing.com (will expire)
From: Pascal Costanza
Subject: Re: ····@
Date: 
Message-ID: <ar16mb$dml$1@newsreader2.netcologne.de>
Marcus Breiing wrote:
> Pascal Costanza <········@web.de> wrote:
> 
> 
>>Anything else? ;)
> 
> 
> Sure ;-)
> 
> What do you think 
> 
> (····@ 
>  (let ((@ 2)) 
>    @)) 
> 
> should return (once you get rid of the macroexpansion-time errors)?

Oh dear! ;)

> Hey, when you're done with ····@, don't forget to abstract-out the
> more interesting parts.  Maybe call it WALKER?

I haven't exposed myself to tree walkers yet - could you or someone give 
me pointer where to read about them?


Thanks,
Pascal

-- 
Given any rule, however �fundamental� or �necessary� for science, there 
are always circumstances when it is advisable not only to ignore the 
rule, but to adopt its opposite. - Paul Feyerabend
From: Nils Goesche
Subject: Re: ····@
Date: 
Message-ID: <87n0obvkew.fsf@darkstar.cartan>
Pascal Costanza <········@web.de> writes:

> Marcus Breiing wrote:

> > Hey, when you're done with ····@, don't forget to
> > abstract-out the more interesting parts.  Maybe call it
> > WALKER?
> 
> I haven't exposed myself to tree walkers yet - could you or
> someone give me pointer where to read about them?

Heh -- I gave you those examples to help you understand that what
you need is a fully-fledged code walker /if/ you really want to
descend into the code to replace the occurrences of @.  Just
google for ``code walker�� to find one, or do (apropos "walk")
because many Lisp implementations already contain one.  However,
all the PROG* forms return simply one of their ``top-level��
forms -- if you do the same, your macro would be much easier to
write -- just don't descend into the code.

Regards,
-- 
Nils G�sche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0
From: Pascal Costanza
Subject: Re: ····@
Date: 
Message-ID: <ar19hq$ke9$1@newsreader2.netcologne.de>
Nils Goesche wrote:
> Pascal Costanza <········@web.de> writes:
> 
> 
>>Marcus Breiing wrote:
> 
> 
>>>Hey, when you're done with ····@, don't forget to
>>>abstract-out the more interesting parts.  Maybe call it
>>>WALKER?
>>
>>I haven't exposed myself to tree walkers yet - could you or
>>someone give me pointer where to read about them?
> 
> 
> Heh -- I gave you those examples to help you understand that what
> you need is a fully-fledged code walker /if/ you really want to
> descend into the code to replace the occurrences of @.  Just
> google for ``code walker�� to find one, or do (apropos "walk")
> because many Lisp implementations already contain one.

Of course - sorry!


Pascal

-- 
Given any rule, however �fundamental� or �necessary� for science, there 
are always circumstances when it is advisable not only to ignore the 
rule, but to adopt its opposite. - Paul Feyerabend
From: Nils Goesche
Subject: Re: ····@
Date: 
Message-ID: <87isyzvj2k.fsf@darkstar.cartan>
Pascal Costanza <········@web.de> writes:

> Nils Goesche wrote:
> > Pascal Costanza <········@web.de> writes:
> >
> >>Marcus Breiing wrote:
> >
> >>>Hey, when you're done with ····@, don't forget to
> >>>abstract-out the more interesting parts.  Maybe call it
> >>>WALKER?
> >>
> >>I haven't exposed myself to tree walkers yet - could you or
> >>someone give me pointer where to read about them?
> > Heh -- I gave you those examples to help you understand that what
> > you need is a fully-fledged code walker /if/ you really want to
> > descend into the code to replace the occurrences of @.  Just
> > google for ``code walker�� to find one, or do (apropos "walk")
> > because many Lisp implementations already contain one.
> 
> Of course - sorry!

Wieso sorry?  Nur falls Du es nicht weiszt, ``Heh�� ist Englisch
fuer ``Hehe��, nicht ``Hey!�� :-)

Bis denne,
-- 
Nils G�sche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0
From: Nils Goesche
Subject: Re: ····@
Date: 
Message-ID: <8765uzvh99.fsf@darkstar.cartan>
I <···@cartan.de> wrote:

[German gibberish]

Sorry.  Was supposed to be mailed.  Maybe I should remap the `F�
or `R� key to some different place on my keyboard...

Regards,
-- 
Nils G�sche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0