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

Re: Multiple values in Dylan



>     Scott, could you give some examples?
> 
> Sure:
> 
> (cons (foo a) (bar b) (bletch c))
> 
> It kind of looks like too many arguments are being passed there, and my
> sophisticated syntax-checking editor just complained.  But in this case
> it's OK, since bar really does some side-effect and returns zero values, so
> it acts sort of like a comment -- drop it in code anywhere.  BAR isn't
> written yet, so none of the programming tools know that it's going to be
> zero-valued.
> 

As I understand it, this example would not be okay in Jim's version of
multiple values in Dylan.  Bar is being called in a position that
expects one value, but the bar you describe is returning no values.  A
continuation passing version of the expression follows.  Clearly, cons
is being called with too many arguments.

(foo
 a
 (lambda (foo-a)		; Foo's continuation
   (bar
    b
    (lambda (bar-b)		: Bar's contination
      (bletch
       c
       (lambda (bletch-c)	; Bletch's continuation
	 (cons
	  foo-a
	  bar-b
	  bletch-c
	  initial-continuation)))))))

You must call bar from an expression that expects exactly zero
values or from an expression that accepts any number of return values.
Try begin as in:

(begin (bar b) #t)

> (+ (foo a) (bar b) (bletch c))

This example is also in error for the same reason as the previous one.

John