[chuck-users] easy random numbers

Scott Wheeler wheeler at kde.org
Tue Nov 20 21:57:31 EST 2007

Kassen wrote:
> I'm sure this is very naive again, but we do have lots of support for 
> adding and subtracting time. We have both "time" and "duration" as 
> datatypes and day, hour, minute,etc, etc, etc as constants ready made.
> If we'd have even -say- a function that would report the amount of 
> samples that have passed since newyear 2000 in our timezone it would 
> be quite straightforward to discover the amount of time until "tomorow 
> at noon".

Well, but the trick in that question is, "What if daylight savings time 
starts tonight?"  I should have made that more clear.

That may sound like a contrived example, but to put it in context, let's 
say that you have a multimedia installation that's doing something 
connected with time.  You've got ChucK running and it may sit there 
running for a week.  Every day it's supposed to do something at noon 
that is synchronized to other parts of the piece.  So you compute a 
duration until noon tomorrow and chuck that to now.  But then it doesn't 

> The hard bits -as I see it- would be that daylight saving time is 
> variable per country [...]

There are faculties on the systems to handle those things -- either via 
system APIs or using something like boost in the background, it's more a 
question of how much of that would need to be exposed in a time class 
for ChucK.

> Admittedly that would be a bit abstract at the expense of ease of use 
> for most people most of the time but I don't think that a API to 
> reason about time as such is the bottle-neck here.

Well, I suppose the question that I'm really hinting at is, "What 
problem are you trying to solve?"  That's really the question behind API 
design.  For a lot of potential answers to that question the answer 
results in an API that's a bit of work to implement.  "ChucK doesn't 
support time." isn't really a good starting point.  "I'd like to be able 
to do ..." is better.  For the one proposed case so far (seeding the 
random number generator) that seems to be more of a problem that there's 
a bug in ChucK's code somewhere and there I feel like the right solution 
is fixing the bug.  :-)


More information about the chuck-users mailing list