[Top][All Lists]

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

Re: [Chicken-users] Stupid backquote/unquote question

From: John Cowan
Subject: Re: [Chicken-users] Stupid backquote/unquote question
Date: Thu, 21 Feb 2008 04:13:00 -0500
User-agent: Mutt/1.5.13 (2006-08-11)

Hans Nowak scripsit:

> ...and I understand *why* they don't work, but I can't figure out how to 
> take s and transform it into (foo bar 42).  Maybe I'm stupid, but I just 
> don't see it. Is it possible?  Or do I need to do something entirely 
>  different?

As has been pointed out, you can use eval, but you can also use your
own quasiquote expander.  Attached is a copy of Alan Bawden's, which is
used in the syntax-case egg.    The interface is just (qq-expand sexpr);
the other functions are private helpers.  Someone should eggify this,
I guess.)

Alan's code has an extension over R5RS: if you pass it `(+ (unquote
1 2 3) 4) it will return (+ 1 2 3 4) rather than reporting an error
or just throwing away the "2 3" part, as Chicken's native quasiquote
expander does.  You can see this happen by testing the expression when
running csi with and without syntax-case.

Newbies always ask:                             John Cowan
  "Elements or attributes?            
Which will serve me best?"                      address@hidden
  Those who know roar like lions;
  Wise hackers smile like tigers.                   --a tanka, or extended haiku

Attachment: qq-expand.scm
Description: Text document

reply via email to

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