unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Damien Mattei <damien.mattei@gmail.com>, guile-user <guile-user@gnu.org>
Subject: Re: reserved-keyword in macro
Date: Fri, 04 Feb 2022 17:44:07 +0100	[thread overview]
Message-ID: <4ee1da97bf91dda65fc3018ce34a99804b4dec2f.camel@telenet.be> (raw)
In-Reply-To: <CADEOadc0Syewf80ZkgMF2judui0gQCU0NjgyPCwigbu4552WEg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 953 bytes --]

Damien Mattei schreef op vr 04-02-2022 om 17:24 [+0100]:
> even with $nfx$ it does not seem to be possible without set!-values:
> https://docs.racket-lang.org/reference/set_.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._set%21-values%29%29
> 
> does someone know how to implement set!-values in Scheme for Guile?

This is not Guile-specific, it works in any Scheme with syntax-rules,
by using a form of recursion, call-with-values, set!, lambda and
values, see attachement (LGPL3.0+ licensed).

Also, Racket is free software, so you could look at the source code of
Racket, maybe Racket's implementation can be ported to Guile Scheme and
maybe it's already valid Guile Scheme.

> On Fri, Feb 4, 2022 at 9:21 AM Damien Mattei <damien.mattei@gmail.com>
> wrote:
> [ a huge block of text ]

This block of text does not appear to have anything to do with your
question, what is it included for?

Greetings,
Maxime.

[-- Attachment #1.2: Type: text/plain, Size: 1149 bytes --]

;;; Copyright © 2022 Maxime Devos
;;;
;;; This library is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This library is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; Lesser General Public License for more details.
;;;
;;; You should have received a copy of the GNU Lesser General Public
;;; License along with this program.  If not, see
;;; <http://www.gnu.org/licenses/>.

(define-syntax set!-values
  (syntax-rules ()
    ((_ (var var* ...) exp)
     (call-with-values
       (lambda () exp)
       (lambda (value . rest)
         (set! var value)
         (set!-values (var* ...) (apply values rest)))))
    ((_ () exp)
     (call-with-values
       (lambda () exp)
       (lambda () (values)))))) ; nothing to do!

(define x)
(define y)
(define z)
(set!-values (x y z) (values 0 1 2))
(pk x y z)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

      reply	other threads:[~2022-02-04 16:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 10:13 reserved-keyword in macro Damien Mattei
2022-02-02 10:33 ` Maxime Devos
     [not found]   ` <CADEOaddzjFbSYvVGEOkrSrjHSZvUkqC9beiRw29jbH3XHeRkZw@mail.gmail.com>
2022-02-02 13:02     ` Fwd: " Damien Mattei
2022-02-02 21:23       ` Damien Mattei
2022-02-02 21:38         ` Damien Mattei
2022-02-03  0:52           ` Vijay Marupudi
2022-02-03 10:09             ` Damien Mattei
2022-02-04  8:21               ` Damien Mattei
2022-02-04 16:24                 ` Damien Mattei
2022-02-04 16:44                   ` Maxime Devos [this message]

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=4ee1da97bf91dda65fc3018ce34a99804b4dec2f.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=damien.mattei@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).