Explanation of macros; Haskell macros
Olaf Klischat
olaf.klischat at isst.fhg.de
Fri Oct 31 14:52:19 EST 2003
"Coby Beck" <cbeck at mercury.bc.ca> writes:
> "Pascal Costanza" <costanza at web.de> wrote in message
> news:bnscfb$p1k$1 at newsreader2.netcologne.de...
>>
>> The essence of this is as follows:
>>
>> (defmacro my-cond (&body body)
>> `(cond ,@(append body '(t (handle-the-default-case))))
>>
>
> Just to provide a more apparently general (and working ;) version, analogous
> to CL's ECASE:
>
> CL-USER 90 >
> (defmacro econd (&body body)
> `(cond ,@(append body
> `((t (error (format nil
> "fell through ECOND form. could not
> satisfy any of the following: ~{~%~A~}~%"
> (mapcar #'(lambda (cond)
> (car cond))
> ',body))))))))
Just for the record: Is the "append" stuff necessary? Why not write
this as
(defmacro econd (&body body)
`(cond , at body
(t (error (format nil "fell through ECOND form. could not satisfy any of the following: ~{~%~A~}~%"
',(mapcar #'(lambda (cond)
(car cond))
body))))))
?
Olaf
--
Olaf Klischat | Fraunhofer ISST
Oberfeldstrasse 132 | Mollstrasse 1
12683 Berlin, Germany | 10178 Berlin, Germany
phone: +49 30 54986231 | mail: olaf.klischat at isst.fhg.de
More information about the Python-list
mailing list