Re: [chuck-users] [chuck] chuck-1.2.0.6 released (also miniAudicle)
Ge Wang wrote:
chuck-1.2.0.6 (dracula), a minor release, is now available:
Unfortunately this release doesn't work with my in-progress system written in chuck. I have the following (heavily snipped): public class timeEvent extends Event{ } public class Time { static timeEvent quarter; fun static void send(){ while(true){ "length of quarter note" => now; Time.quarter(broadcast); } } } This mean that I can have the following (not snipped, this is a complete .ck file, extremely compact and elegant) for four-on-the-floor: while (true){ Time.quarter => now; spork ~ Instruments.analog_bd(); } Now, running the new release I get: [time.ck]:line(34): cannot declare static non-primitive objects (yet)... [time.ck]:line(34): ...(hint: declare as ref (@) & initialize outside for now) Where line 34 is exactly: static timeEvent quarter; Could/should I really change my code to work with this release, following the above suggestion? In any case, I'd rather not clutter up things, I think (at this point) the old way of doing things was fine. Besides I have 9878 lines of chuck code in my system, so not to confuse things... -- peace, love & harmony Atte http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
Ge Wang wrote:
chuck-1.2.0.6 (dracula), a minor release, is now available:
Unfortunately this release doesn't work with my in-progress system written in chuck.
I have the following (heavily snipped):
public class timeEvent extends Event{ }
public class Time { static timeEvent quarter;
fun static void send(){ while(true){ "length of quarter note" => now; Time.quarter(broadcast); } } }
This mean that I can have the following (not snipped, this is a complete ..ck file, extremely compact and elegant) for four-on-the-floor:
while (true){ Time.quarter => now; spork ~ Instruments.analog_bd(); }
Now, running the new release I get:
[time.ck]:line(34): cannot declare static non-primitive objects (yet)... [time.ck]:line(34): ...(hint: declare as ref (@) & initialize outside for now)
Where line 34 is exactly:
static timeEvent quarter;
I had the same problem. This can be resolved quite simple. static timeEvent @ quarter; new timeEvent @=> quarter; At least this works for me. ___________________ w31rd0
Could/should I really change my code to work with this release, following the above suggestion? In any case, I'd rather not clutter up things, I think (at this point) the old way of doing things was fine. Besides I have 9878 lines of chuck code in my system, so not to
confuse
things...
-- peace, love & harmony Atte
http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
w31rd0 wrote:
static timeEvent @ quarter; new timeEvent @=> quarter;
That seems to work, thanks. Apparently I'm to stupid to figure out how to do the same split declaration/instantiation with arrays such as: static int ids[10]; How would that look when rewritten? -- peace, love & harmony Atte http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
w31rd0 wrote:
static timeEvent @ quarter; new timeEvent @=> quarter;
That seems to work, thanks.
Apparently I'm to stupid to figure out how to do the same split declaration/instantiation with arrays such as:
static int ids[10];
Chuck doesn't allow to declare references on primitive types. But it seems to allow to declare an empty array, which actually is a reference (or should be :) static int ids[]; new int[10] @=> ids; it works in a single line either: new int[10] @=> static int ids[]; ___________________ w31rd0
How would that look when rewritten?
-- peace, love & harmony Atte
http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
w31rd0 wrote:
new int[10] @=> static int ids[];
Thanks. Very nice. I can at least report that the "public classes can now internally reference non-public classes in the same file" works for me. -- peace, love & harmony Atte http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
Howdy!
static timeEvent @ quarter; new timeEvent @=> quarter;
That seems to work, thanks.
To further clarify, the declaration of the static timeEvent @ quarter is inside the class, but the initialization new timeEvent @=> quarter should be outside in this case. Otherwise, quarter gets reinitialized every time the class is instantiated - or quarter never gets initialized if the class is never instantiated. So the code should probably be something like: --- public class timeEvent extends Event { /* etc */ } public class Time { // declare as reference (@) static timeEvent @ quarter; fun static void send() { while(true) { /* code */ } } } // initialize outside (temporary workaround) new timeEvent @=> Time.quarter; --- Same with any static objects, including arrays. The new error message: : cannot declare static non-primitive objects (yet)... : ...(hint: declare as ref (@) & initialize outside for now) is just there temporarily to point out the static declaration doesn't fully work until static members are fully fixed. we reckon it's probably better to err out rather than allow misleading code due to compiler bugs, yeah? Best wishes, Ge!
Ge Wang wrote:
To further clarify, the declaration of the static timeEvent @ quarter is inside the class, but the initialization new timeEvent @=> quarter should be outside in this case. Otherwise, quarter gets reinitialized every time the class is instantiated - or quarter never gets initialized if the class is never instantiated.
I only instantiate once (had two cases). It seems to work flawlessly. And I actually don't rely on the event to be initialized before use... -- peace, love & harmony Atte http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
participants (3)
-
Atte André Jensen
-
Ge Wang
-
w31rd0