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

possible alternative for use with a corresponding define extension?

Out of curiosity, might it be more generally useful to enable the definition
of multiple symbols globally than locally within a let, and support local
function defs within a let which are syntactically similar to that of
define, as an alternative to the presently defined syntax? i.e.:

  (define ((x y . z)) ; exported defs.
    (let* ([a 1] [b 2] ; not exported.
           [(f c . d) (+ a c (car d))]
           [(g e) (+ b e (f b 5 6))])
      (values f g a b))
   (x 2 3 4) => 6 ; (+ 1 2 3)
   (y 5) =>  18 ; (+ 2 5 (+ 2 5 6))
   z => (1 2)
   a => <undefined>
   b => <undefined>

Thereby enabling a basic simple and consistent means for a module facility,
where ideally newly defined multiple values are limited to within the
current scope and not beyond (thereby if such definitions are loaded
within the context of a let, they are only visible beyond the scope of the
let if explicitly correspondingly effectively exported by a higher level
multiple symbol define:

  (define ((x y)) ; defining x y in it's scope.
    (load "some-module.ss") ; defining x1 y1 z1 locally.
    (let ([x2 x1] [(y2 a b) (y1 (+ a 1) b)]) ; redefining y1.
      (values x2 y2))) ; exporting x1 and redefined y1, but not z1

Where then multiple value defs may be enabled within within a let:

  (let ([((x y . z)) (values 1 2 3 4)]) (list x y z)) => (1 2 (3 4))
as being correspondingly similar to a multiple value extension of define?

And as an aside, it would seem that a multi-value (list ...) could be used
as effective alternative to (values ...) for the purpose of returning
multiple symbol value definitions?