[chuck-users] cast dur to time?

pibsid at suomi24.fi pibsid at suomi24.fi
Tue Jan 8 10:35:03 EST 2008

Mike wrote:
>>Still, this would be sugar. 

>>I really like the argument that if (time / duration = float) is legal, then (time / float = duration) should also be legal, however, it also follows that (time = duration * float), which I don't like.  (2::second * 4) ought to return 8::second.  So, I think that we're dealing with concepts here that don't fit squarely into the model of mathematics.  After all, we don't multiply strings and floats, do we?

>>I'm all for a more rigorous understanding of these types, though.  This is all very confusing.


What I think we're dealing with here mathematically is affine spaces.
In an affine space you have points and vectors that connect them. The difference between a regular vector space is that there is no "true" origo but everything is relative. Also the operations on points differ from operations with vectors.

Here the big letters denote points in an affine space and small letters denote vectors:
-For each two points A and B we have an unambigious vector ab that connects them.
-For each three points A, B and C: ac = ab + bc

A - B = x
A + x = B
A + B = (undefined), (How do you add points together? Makes no sense)
And thus A*(scalar) = (undefined), (In a vector space all this would be legal)

Compare to time:
time - time = dur;
time + dur = time;
time + time = (undefined)
time*float = (undefined)

The point (no pun intended) with affine spaces is that you can only make new points if you already have at least one to begin with. You can't just throw in a point if you don't define how it relates to the points already present.

For the syntax issues I see no harm in adding 
me.bith = the time since the VM's start that the shred was sporked.

To me it's just not a big deal to type: now => time birth; At the beginning of a sporkable funtion. 
But hey. We all find different things intuitive or counter-intuitive.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080108/8a9aaf4f/attachment.htm 

More information about the chuck-users mailing list