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

Re: [Scheme-reports] multiple values module



5 minutes ago, John Cowan wrote:
> Andy Wingo scripsit:
> 
> > There is also the approach of using no type at all and returning
> > the values on the stack.
> 
> Indeed, though that can lead to very strange behavior.  For example,
> if the identifier "map" is known to be bound to its R5RS definition,
> a compiler can reject (map (foo)) as erroneous, but under a "return
> on the stack" implementation, (foo) might return both the function
> and the list to map.  I think it was Henry Baker who pointed this
> out.

No, returning multiple values through a stack is *unrelated* to
implementing the language you're describing.

Here's a racket implementation, BTW:

  #lang racket
  (define-syntax-rule (vals expr ...)
    (append (call-with-values (lambda () expr) list) ...))
  (define-syntax-rule (app f expr ...)
    (let ([l (vals f expr ...)]) (apply (car l) (cdr l))))
  (provide (rename-out [app #%app])
           (except-out (all-from-out racket) #%app)))

This implementation would work regardless of the implementation of
MVs.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports