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

multiple-value set!

This page is part of the web mail archives of SRFI 71 from before July 7th, 2015. The new archives for SRFI 71 contain all messages, not just those from before July 7th, 2015.

Since the SRFI draft not only extends the "let" family to support
multiple-values, but also defines useful procedures for dealing with
multiple-values, would the extension of "set!" to multiple-values also
be within the scope of the SRFI?

If the SRFI-71 "let" forms support a binding expression pattern
language, "set!" should support the same pattern language.

The following simple R5RS implementation intentionally does not support
the "(rest VAR)" syntax that I suggested earlier for "let".  I like that
syntax less in "set!", since I'd like to reserve list syntax in a "set!"
VAR position to be for the generalized-"set!" found in some Lisps.  In
generalized-"set!", "rest" would be a keyword stomping on identifier
space (for which there is precedent in R5RS, but that leads to hygiene

(define-syntax %srfi71:r5rs-set! (syntax-rules () ((_ X ...) (set! X ...))))

(define-syntax srfi-set!
  (syntax-rules ()

    ((_ VAR EXPR)     (%srfi71:r5rs-set! VAR EXPR))

    ((_ S0 S1 S2 ...) (%srfi71:set!:mult (S0 S1 S2 ...) () ()))))

(define-syntax %srfi71:set!:mult
  (syntax-rules (rest)

    ((_ (EXPR) TVS (SET0 ...))
     (call-with-values (lambda () EXPR) (lambda TVS SET0 ...)))

      (S0 S1 ...) (TV0 ...     ) (SET0 ...                              ))
      (   S1 ...) (TV0 ... temp) (SET0 ... (%srfi71:r5rs-set! S0 temp))))))