typing in bind of (value x y z) form 
Author Message
 typing in bind of (value x y z) form

using Thomas 1.1 on Gambit 1.9:

ok, i can do
1)

(bind ((x 2) (y 3))
        (+ x y))

even
2)

(bind (((x <integer>) (2)) (y 3))
        (+ x y))

also
3)

(bind (( x y (values 1 2)))
        (+ x y))

but in thes last example, what if I had already done
4)

(define y (quote <integer>))

will not 3) look close to 2), is 3) allowed if I have
done 4)
?

and is there a type <boolean> and why not.
--
*----------*-------------------------------------------------------------*
| Sam   Jam|"Never underestimate the importance of a cheap laugh"-       |




Mon, 04 Dec 1995 19:57:50 GMT  
 typing in bind of (value x y z) form

I think you need to count your parentheses carefully.  (That's one of
the bad aspects of LISP syntax.)  Let me see if I can make a few
comments here and clear some things up...


Quote:
>ok, i can do
>1)

>(bind ((x 2) (y 3))
>    (+ x y))

Yes, and you get exactly what you expect.

Quote:
>2)

>(bind (((x <integer>) (2)) (y 3))
>    (+ x y))

First of all, there is a syntax error here.  You are trying to invoke
the integer 2 as a function when you type "(2)."
Assuming that typo corrected, notice that you DO still need that extra
set of parentheses you put around "x" and "<integer>."  This is not a
function invokation; it is a part of the Dylan syntax that specifies
that the "x" is the variable to bind and that "<integer>" is a type
specializer.

Quote:
>3)

>(bind (( x y (values 1 2)))
>    (+ x y))

Again, this works as expected.

Quote:
>but in thes last example, what if I had already done
>4)

>(define y (quote <integer>))

There are two problems here.  First, "(quote <integer>)" evaluates to
be the SYMBOL <integer>.  That's it.  Period.  This symbol has no
inherent meaning.  The value of the expression is NOT what some
implementations might write as {the class <integer>}.

Second, even if you had written:
        (define y <integer>) the lack of those extra parentheses
around the "x y" is what makes the difference.  Now suppose you had
done the aforementioned (UNquoted) define.  Then

(bind (( (x y) (values 1 2) ))
  (+ x y))

would be an error.  x would be specialized as an integer and bound to 1.
The second value, 2, would be thrown out, because there is nothing to
do with it.  Then y's value would still be {the class <integer>}, so
you would be trying to add an integer and a class.

Please let me know if I haven't been clear.

                                        Jonathan Sobel



Tue, 05 Dec 1995 08:12:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Defining multiple-values binding forms

2. Expected type of value of form

3. multipart form data & other form values

4. (values (multiple-value-form)) whats the point?

5. type-bound procedures and type extension

6. named-let* ; distinct ids in binding forms

7. IEEE MOTIF/Ada Binding Group forming

8. Declaring variables bound by WITH-x forms SPECIAL

9. Bind canvas form with Tix ??

10. Need Standard Update form to return a value.

11. How Do I Pass Values Between Two Forms

12. help setting a value to a local field variable on a form

 

 
Powered by phpBB® Forum Software