type inferrer

1 view
Skip to first unread message

justin seliger

unread,
Dec 2, 2010, 1:14:02 AM12/2/10
to BYU CS 330 Fall 2010
me:  Hey Jay, Robby and I had a question.  In the function alpha-vary, it says that hash-set and such will be useful, but we are wondering why don't we just type case on the expression and rewrite any id we find with a gensym?
instead of storing it that is
 Jay:  you have to make sure you change bound occurrences to the same thing you changed the binding occurrence to
 me:  OOooOOoo
 Jay:  ie, (fun (x : number) x) should be (fun (x111 : number) x111) not (fun (x111 : number) x234)
 me:  that makes sense
 Jay:  send this conversation to the mailing list, please
 me:  okay
thx
 Sent at 10:19 PM on Wednesday
 me:  Jay, So, we are making a hash... and using hash set.. but its not setting anything. and we are confused. and very sad.
We define the hash using make-immutable hasheq initializing it wiht empty
then do hash-set x (gensym x)
then hash ref x.... and we get nothing
we are also printing out the hash inbetween setting and reffing.. and it is empty
any idea why this is happening?
 Jay:  show me your program
 me:  i just emailed it to u
you*
 Jay:  hash-set returns a new hash table with the change
 me:  we also tried hash-set!~
 Jay:  you are looking at the old one from before the change
 me:  err hash-set!
 Jay:  you should use hash-set
just use it correctly
 me:  so we should re define the hash after each time we use hash-set
?
 Jay:  you could think of it that way
you should never change the hash except when new ids are introduced
never when they are used
 me:  I'm sorry, but i'm not sure i understand.
you mean that we should be using hash-set in the typecase of id
and just using alpha-vary everywhere else?
 Jay:  no
id is when ids are used
 Sent at 10:55 PM on Wednesday
 me:  ...
i dont understand
i'm sorry. but that jsut confused me more
just*
Could you explain that in different words again please?
 Jay:  "id" appears in programs when identifiers are used
eg (fun (x:number) x) the second x is an "id" data structure
because x is "used"
in contrast, the first x is when the identifier is introduced
 me:  ahh
okay.
what about the following:
(alpha-vary (parse 'x))
that should return
(id x)
well the parse should
thus the alpha vary should return
(id x12342)
so would that count as being introduced? or used?
 Jay:  that is being used
and never introduced
so it is an error
 me:  i see.
a parse error?
 Jay:  no an alpha-vary error
Reply all
Reply to author
Forward
0 new messages