chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Stupid backquote/unquote question


From: Hans Nowak
Subject: [Chicken-users] Stupid backquote/unquote question
Date: Thu, 21 Feb 2008 01:59:12 -0500
User-agent: Thunderbird 2.0.0.0 (Macintosh/20070326)

This is more of a general Scheme question...

Let's say I have the following definitions:

#;1> (define magic 42)
#;2> (define s '(foo bar ,magic))

Now I want to replace ",magic" with its value. If I write this directly with backquote and unquote, it's easy and straightforward:

#;3> `(foo bar ,magic)
(foo bar 42)

So far, so good.  But: how do I do the same with the existing list s?

The following doesn't work:

#;4> `s
s
#;5> `,s
(foo bar (unquote magic))

...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?

The underlying idea is that I want to write some sort of DSL, using s-expressions, but it should be possible to insert ,values into it that get evaluated as usual. E.g.

  (jmp #xC000)

should be functionally the same as

  (define foo #xC000)
  (jmp ,foo)

Thanks,

--Hans





reply via email to

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