[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help porting someone else's macro from 4 to 5.

From: megane
Subject: Re: Help porting someone else's macro from 4 to 5.
Date: Tue, 21 Jan 2020 09:50:34 +0200
User-agent: mu4e 1.0; emacs 25.1.1

Andrew Mack <address@hidden> writes:

> Hello all, I'm attempting to port the sdl-mixer egg (originally by
> Christian Kellermann) from 4 to 5. I think I've made most of the
> necessary changes, but  I'm running into a bit of an issue and would
> greatly appreciate some help troubleshooting.

Hi, Andrew!
> I'm a bit new to Chicken and lisp in general, and while I feel I have a
> decent understanding of regular macros the er- and ir-macro-transformer
> procedures are still eluding me somewhat. In sdl-mixer's chicken 4
> source, we have the macro 
> (module sdl-mixer-lolevel 
> (import ... srfi-1 ...) 
> ... 
> (define-syntax --sdl-flags
>  (lambda (e r c)
>   `(,(r 'begin)
>      ,@(append-map (lambda (str)
append-map is being called during syntax expansion time here. So,
instead of (import srfi-1) you need (import-for-syntax srfi-1).

>         (let* ((sym (string->symbol str))
>                 (psym (string->symbol (string-append "-" str))))
>           `((,(r 'define-foreign-variable) ,psym unsigned-integer ,str)
>             (,(r 'define) ,sym ,psym))))
>         (cdr e))))) 
> ... 
> ) ; end module 
> Looking through various chicken documentation, my first assumption was
> to wrap the lambda argument to define-syntax in an er-macro-transformer
> call. However this does not recognize append-map (of course defined in
> srfi-1) as bound. I thought that it might also need to be renamed with
> (r 'append-map) but this also did not work. 
> Since I am new to Chicken, I assume its a misunderstanding on my part of
> what is necessary, but I cannot figure out where to go from here. So
> first of all, is my assumption that I need an er-macro-transformer
> correct, or am I barking up the wrong tree? Second, after resolving the
> first question what is the next step I need to take? Any help would be
> greatly appreciated.

You're correct in that you need to use er-macro-transformer from
(chicken syntax).

Alternatively you can use ir-macro-transformer:

(define-syntax --sdl-flags
   (lambda (e i c)
        ,@(append-map (lambda (str)
                        (let* ((sym (string->symbol str))
                               (psym (i (string->symbol (string-append "-" 
                          `((define-foreign-variable ,psym unsigned-integer 
                            (define ,sym ,psym))))
                      (cdr e))))))
> Thanks in advance, 
> Andrew Mack

reply via email to

[Prev in Thread] Current Thread [Next in Thread]