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.mat...@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.
;;; 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)
signature.asc
Description: This is a digitally signed message part