Refnum

Stephen Weeks MLton@sourcelight.com
Thu, 20 Sep 2001 12:56:44 -0700


> Sure,  once  you  are  willing to re-define ref's it is all easy.  I actually
> don't see why your ref was so complicated.  Why not just do
...

I like your solution too.  I was mostly trying to respond to your statement that
implied that it was clear from the signature that what Norman wanted is
unachievable without cast.  

> The  point  is  that  if you are willing to make a new type (instead of refs)
> then you can clearly have a polymorphic function that only uses the int  part
> of  what  is  stored  there.   You  could  probably  make the above more time
> efficient (although less space efficient) by changing
>     (int option * 'a) ref
> to
>     int option ref * 'a ref

My solution was, to my eye, less of a tweak of refs, which just goes to show
it's not obvious that it can't be done without the tweak.

At present, I'm still trying to think of how to do it if polymorphic equality on
refs were of type 'a ref * 'b ref -> bool.  If you think of it for this, or the
original problem, let me know.