[gambit-list] Gambit-C macros
Bob McIsaac
bobmc_net at rogers.com
Sun Aug 26 22:36:14 EDT 2012
On 08/26/2012 06:49 PM, Mikael wrote:
>>I'm not clear about what you are trying to achieve here.
Thanks, Mikael, for your helpful reply. In addition to understanding
Gambit specifics, I was trying to create WHEN. I finally found a couple
of examples in "Teach Yourself Scheme in Fixnum days" .. they both work
although quoted version needed adjustment.
(define-macro _when ;; alternate version
(lambda (test . branch)
(list 'if test
(cons 'begin branch))))
(define-macro when
(lambda (test . branch)
`(if ,test {IF and BEGIN from the example uppercase did not work}
(begin , at branch))))
=Bob=
> First note there is more than one code/macro expander for Gambit:
> Gambit's default, the one with Black Hole, and the syntax-case library
> file, for instance.
>
> 2012/8/26 Bob McIsaac <bobmc_net at rogers.com <mailto:bobmc_net at rogers.com>>
>
> Hi:
>
> 3 questions...
>
> I'm looking for a "when" macro and tried one patterned on
> "unless". It behaves like "when-not". How do I write a proper
> "when" macro?
>
> (define-syntax when-not
> (syntax-rules ()
> ((when-not test body ...)
> (if test #t (begin body ...)))))
>
> (define (test-when n)
> (when-not (not (< n 50))
> (println "line1 " n)
> (println "line2 " n)
> (println "line3 " n)))
> (test-when 0) (test-when 3) (test-when 55)
> ;-------------------------------------------
>
>
> I'm not clear about what you are trying to achieve here.
>
> Re "define-syntax" the Gambit-C manual says .."Note that this
> implementation of syntax-case does not support special forms that
> are specific to Gambit." What are the implications of this
> statement? Is there a preferred model for writing Gambit-C macros?
>
>
> No support for #!rest #!optional #!key would be a good start. Not
> clear atm about more.
>
> ;------------------------------------------------------------
>
> Some code has a "##" prefix like..
> (##define-macro (err form)
> `(let ()
> (##declare (safe) (generic))
> (err-form (lambda () ,form))))
>
> Why is that?
>
>
> Generally in Gambit ##-prefixes on Gambit-provided procedures is to
> say it's the non-typechecked variant.
>
> As for Gambit-provided syntactical forms (##define-macro ##lambda
> etc.) I believe they're equivalent with the non-prefixed variant.
>
> Brgds
>
> =bob=
>
> ||
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca <mailto:Gambit-list at iro.umontreal.ca>
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20120826/bd231849/attachment.htm>
More information about the Gambit-list
mailing list