unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Maciek Godek" <pstrychuj@gmail.com>
To: guile-user@gnu.org
Subject: set-pair!
Date: Wed, 20 Aug 2008 09:27:48 +0200	[thread overview]
Message-ID: <e2ceda030808200027m53bd490dq6e34a534915dc410@mail.gmail.com> (raw)

Hi,
I've been trying to write a function or macro that
would work like this:

(let ((a 0)(b 0))
  (set-pair! '(a . b) '(1 . 2))
  (cons a b)) ; => (1 . 2)

I eventually wrote:

(define (set-pair! pair values)
  (let ( (e (the-environment)) (a (car pair)) (d (cdr pair)) )
     (local-eval
        `(begin
             (set! ,a ,(car values))
             (set! ,d ,(cdr values)))
         e)))

but it seems to work only for symbols defined in
global scope. Does anyone know how to implement
this form properly?

Thanks in advance
Maciek

PS I love you all :)




             reply	other threads:[~2008-08-20  7:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-20  7:27 Maciek Godek [this message]
2008-08-20 16:34 ` set-pair! Clinton Ebadi
2008-09-11 15:09   ` phase separation -- was set-pair! JonWilson
2008-09-11 15:12     ` Robby Findler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e2ceda030808200027m53bd490dq6e34a534915dc410@mail.gmail.com \
    --to=pstrychuj@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).