unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: Andrew Gwozdziewycz <apgwoz@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: progv in scheme
Date: Tue, 13 Sep 2011 18:04:05 +0200	[thread overview]
Message-ID: <CAMFYt2Y0-G5a42nctmjuTnr6rjpQVTW3VVS3SBtVx15Va7Wj-w@mail.gmail.com> (raw)
In-Reply-To: <CADoGzsf-rKZAp7T4xiVxA++ryvDqN1S3PjXjnAiTBBwrSeKi3A@mail.gmail.com>

2011/9/13, Andrew Gwozdziewycz <apgwoz@gmail.com>:
>
> Seems likely that you could use `syntax-case' to create a `let` out of
> these:
>
> (define-syntax progv
>   (lambda (stx)
>     (define (create-bindings syms vals)
>       (datum->syntax stx (zip (syntax->datum syms) (syntax->datum vals))))
>     (syntax-case stx ()
>       ((_ symbols values body ...)
>        (with-syntax ((bindings (create-bindings #'symbols #'values)))
>           #'(let bindings
>                (begin body ...)))))))
>
>
>
> ;; usage
> (progv (foo bar baz) (1 2 3)
>    (format (current-output-port) "Values: ~a ~a ~a\n" foo bar baz))
> ;; output: "Values: 1 2 3"

Hey,
thanks for this code, maybe one day I will be able to comprehend it :)
for now, the problem is that I want to bind the variables that are
contained within a list, and that I don't know what's in that list.

So, the following code should work as well:
(let ((s '(foo bar baz))
      (v '(1 2 3)))
  (progv s v
     (+ foo bar baz)))
===> 6

regards
M.



  parent reply	other threads:[~2011-09-13 16:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13 13:54 progv in scheme Panicz Maciej Godek
2011-09-13 14:25 ` Andrew Gwozdziewycz
2011-09-13 14:26   ` Andrew Gwozdziewycz
2011-09-13 16:04   ` Panicz Maciej Godek [this message]
2011-09-13 16:35     ` Andrew Gwozdziewycz
2011-09-13 17:01       ` Bill Schottstaedt
2011-09-13 17:54       ` Bill Schottstaedt
2011-09-13 17:20     ` Ludovic Courtès
2011-09-13 17:57 ` Ian Price
2011-09-13 18:48   ` Panicz Maciej Godek
2011-09-13 19:09     ` Bill Schottstaedt
2011-09-13 19:16       ` Andrew Gwozdziewycz
2011-09-15 18:11       ` Andy Wingo
2011-09-15 18:16         ` Andrew Gwozdziewycz

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=CAMFYt2Y0-G5a42nctmjuTnr6rjpQVTW3VVS3SBtVx15Va7Wj-w@mail.gmail.com \
    --to=godek.maciek@gmail.com \
    --cc=apgwoz@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).