[chuck-users] int *=> dur (syntax inconsistency?)

Kassen signal.automatique at gmail.com
Sun Sep 21 23:29:52 EDT 2008


Dear list,

Consider;
===================================
//definition
second => dur foo;

//this is fine
2.0 *=> foo;

//this is not fine
2 *=> foo;
====================

The last line gives a error about not being able to resolve *=> on types int
and dur. I wonder if this is correct behaviour; I can imagine many cases
where a integer multiple of some duration is needed to avoid "trainwrecking"
(a DJ term for two concurent tracks running at slightly different speeds).
While we can obviously express integers as floats as well there may be cases
where the int data-type can make guaranteeing we are dealing with a natural
number easier, for example Std.rand2( ).

while correct I don't think either alternative looks especially nice;

Std.rand2(1,4) * 1.0 *=> foo;
Std.rand2(1,4) $ float *=> foo;

This does work in the comparable case of;

//correct but not as ChucKian
foo * 3 => foo;

or even;

1.2 => float bar;
//implicit casting in *=> does work here
3 *=> bar;


So; I'd like to sugest a implicit casting of int to float or further
overloading *=> in these cases.

Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080922/723332f9/attachment.html>


More information about the chuck-users mailing list