[chuck-users] giving birth made easy (and head-hitting)

Kassen signal.automatique at gmail.com
Fri Jan 11 15:35:26 EST 2008


Dear list,

It turns out that for a VM that has been running for a arbitrarily long time
it's still easy to find the time of it's birth.

considder the following;

=================
time birth;
now - (now /samp)::samp => time start;
if (start == birth) <<<"Yay">>>;
=============================

*hits head*

So, it's possible after all to define objects of type time wthout using time
after all; adding durations to a "fresh" time object will in fact do.

Next up; a poor man's casting;
=============================
//demo
<<<dtot(second)>>>;
<<<ttod(now)>>>;

//the meat
//time to duration and dur to time by Kassen.
//considered trivial once I thought of it
//no rights reserved

fun time dtot (dur input)
 {
 //duration to time
 //probably leaks memory
 time garbage;
 input +=> garbage;
 return garbage;
 }


fun dur ttod (time input)
 {
 //time to duration

 //here we go again with the strong typing
 return ( input/samp )::samp;
 }

====================================

*hits head again*

Cheers,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080111/d8bf66b9/attachment.htm 


More information about the chuck-users mailing list