chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] unbound variable: or


From: Matt Gushee
Subject: Re: [Chicken-users] unbound variable: or
Date: Fri, 29 May 2015 19:29:29 -0600

Hi, Jinsong--

On Fri, May 29, 2015 at 6:25 PM, Jinsong Liang <address@hidden> wrote:

I want to learn some basic macro programming in Chicken. However, it seems there are multiple macro definition APIs in Chicken: define-syntax, syntax-rules, syntax-case, define-macro. Which one should I start with?

It can indeed be a bit confusing, and my knowledge is not very advanced, but here's what I know:

  * define-macro is old. I'm not sure it is even still supported in Chicken 4.x, but
     it's certainly not recommended.

  * define-syntax is currently the primary macro form, and you use it together with syntax-rules. E.g.:
   
        (define-syntax NAME
            (syntax-rules ()
                (PATTERN BODY) .... ))

   * I've never used syntax-case - which is not to say that you shouldn't, but I'm pretty sure it is not considered "basic."

If the Chicken documents don't give you enough information, I've found Kent Dybvig's book _The Scheme Programming Language_ helpful in learning syntax-rules. It's available online at:

    http://www.scheme.com/tspl3/

You want Chapter 3 and maybe also Chapter 8. There is now a 4th edition of the book, but it covers R6RS Scheme; I think the 3rd edition is more applicable to Chicken.
 
Also, I have heard that, different from Lisp, macro programming in Scheme is not recommended. Is it true?

I wouldn't put it that way, but what I have always heard is that you shouldn't use a macro when a procedure will work.
 
HTH.

--
Matt Gushee

reply via email to

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