Hello, I have a few chuck language questions: Is it possible to define a "growing" array? The associative portion of the array grows without bounds but I can't see how to do that with the indexed portion. Object @ list[]; for (0 => int i; i < 100; i++) { Object o @=> list[i]; } Is it possible to check a reference against null? Object @ list[100]; 0 => int size; for (0 => int i; i < list.cap(); i++) { if (list[i] is null?) { size++; } } Is there a "String toString()" or similar method on Object? I wish to override "Expressions which represent an object will print the value of that object's reference address". Do reflective methods exist on the base Object type (its "Class")? e.g. Function[] getFunctions(); ... Thanks, michael
A couple more: If an array is defined but not instantiated with a capacity Object @ values[]; should it be possible to instantiate it later with a capacity of nulls? Object @ [100] @=> values[]; How about a cast? class MyEvent extends Event { int value; } fun void handleEvent(Event event) { <<< ((MyEvent) event).value >>>; } Thanks, michael Michael Heuer wrote:
Hello,
I have a few chuck language questions:
Is it possible to define a "growing" array? The associative portion of the array grows without bounds but I can't see how to do that with the indexed portion.
Object @ list[]; for (0 => int i; i < 100; i++) { Object o @=> list[i]; }
Is it possible to check a reference against null?
Object @ list[100]; 0 => int size; for (0 => int i; i < list.cap(); i++) { if (list[i] is null?) { size++; } }
Is there a "String toString()" or similar method on Object? I wish to override "Expressions which represent an object will print the value of that object's reference address".
Do reflective methods exist on the base Object type (its "Class")? e.g. Function[] getFunctions(); ...
Thanks,
michael
Hello,
AFAIK there is no mechanism to alter the capacity of an array, and at
present not much else in the way of handy data structures. This is
something I've been meaning to ask about myself, though. I've only been
using ChucK for a short time...
As for the question on reflection... I don't think there is anything like
that there now, and somewhat doubt there will be soon... I certainly haven't
seen anything about it in the docs. If you want to find out, for example,
if there is a "String toString()" method defined for Object, perhaps the
simplest thing is to read the source code... maybe that isn't a very
constructive comment, though. Maybe you really do want to use reflection
generally... could be useful.
Cheers,
Peter
<<<"More text among the quote...">>>;
On Nov 9, 2007 8:50 PM, Michael Heuer
If an array is defined but not instantiated with a capacity
Object @ values[];
should it be possible to instantiate it later with a capacity of nulls?
Object @ [100] @=> values[];
Was this what you were after? Object @ values[]; Object @ foo[100] @=> values; How about a cast?
class MyEvent extends Event { int value; }
fun void handleEvent(Event event) { <<< ((MyEvent) event).value >>>; }
Casts are done differently, with the $ symbol. For example:
class MyEvent {
int value;
}
fun void handle(Event e){
e $ MyEvent @=> MyEvent e2;
<<
Thanks,
michael
Michael Heuer wrote:
Hello,
I have a few chuck language questions:
Is it possible to define a "growing" array? The associative portion of the array grows without bounds but I can't see how to do that with the indexed portion.
Object @ list[]; for (0 => int i; i < 100; i++) { Object o @=> list[i]; }
Is it possible to check a reference against null?
Object @ list[100]; 0 => int size; for (0 => int i; i < list.cap(); i++) { if (list[i] is null?) { size++; } }
Is there a "String toString()" or similar method on Object? I wish to override "Expressions which represent an object will print the value of that object's reference address".
Do reflective methods exist on the base Object type (its "Class")? e.g. Function[] getFunctions(); ...
Thanks,
michael
chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Greetings!
AFAIK there is no mechanism to alter the capacity of an array, and at present not much else in the way of handy data structures. This is something I've been meaning to ask about myself, though. I've only been using ChucK for a short time...
Definitely an essential feature. Dynamic/resizable arrays are currently not in the language, but we recently implemented it in ChucK and are currently in the testing phase. Most likely it will be in the next release. Best, Ge!
Ge Wang wrote:
Greetings!
AFAIK there is no mechanism to alter the capacity of an array, and at present not much else in the way of handy data structures. This is something I've been meaning to ask about myself, though. I've only been using ChucK for a short time...
Definitely an essential feature. Dynamic/resizable arrays are currently not in the language, but we recently implemented it in ChucK and are currently in the testing phase. Most likely it will be in the next release.
Thanks. Not sure if this mailing list handles attachments or not, but attached is where I was going with my "List" implementation. The file also includes a bunch of small functor classes, something like function pointers. michael
Ge Wang wrote:
[snip] we recently implemented it in ChucK and are currently in the testing phase. Most likely it will be in the next release.
That's great, looking forward to that! -- peace, love & harmony Atte http://atte.dk | http://myspace.com/attejensen http://anagrammer.dk | http://modlys.dk
On Nov 10, 2007 2:45 AM, Ge Wang
Definitely an essential feature. Dynamic/resizable arrays are currently not in the language, but we recently implemented it in ChucK and are currently in the testing phase. Most likely it will be in the next release.
Ha! New address, all settled in? :-)
If you remember a while back I had some questions about the .cap() of
multi-dimensional arrays? Well, back then I did some poking around and it
seems we sorta kinda do have resizable arrays;
int foo[8];
1 => foo[1];
<<
Ge Wang wrote:
Greetings!
AFAIK there is no mechanism to alter the capacity of an array, and at present not much else in the way of handy data structures. This is something I've been meaning to ask about myself, though. I've only been using ChucK for a short time...
Definitely an essential feature. Dynamic/resizable arrays are currently not in the language, but we recently implemented it in ChucK and are currently in the testing phase. Most likely it will be in the next release.
Best, Ge!
Just as a follow up, a good place to get inspiration fro Array methods is SC. I think this essential in any algorithmic composition environment (without any specific preference order): reverse scramble mirror rotate add addFirst insert removeAt pop first last fill etc... I imagine that after the "guts" of arrays are implemented on C++ for the language, most of these methods cold be implemented directly as chuck classes. Looking froward for them! JPa.
.... Although .net manages to get by without resizable arrays. Not that I think that's a good idea; but, as language features go, it's a luxury, not a requirement, as .net demonstrates. Robin Davies -----Original Message----- From: chuck-users-bounces@lists.cs.princeton.edu [mailto:chuck-users-bounces@lists.cs.princeton.edu] On Behalf Of Ge Wang Sent: Friday, November 09, 2007 8:45 PM To: ChucK Users Mailing List Subject: Re: [chuck-users] a few language questions Greetings!
AFAIK there is no mechanism to alter the capacity of an array, and at present not much else in the way of handy data structures. This is something I've been meaning to ask about myself, though. I've only been using ChucK for a short time...
Definitely an essential feature. Dynamic/resizable arrays are currently not in the language, but we recently implemented it in ChucK and are currently in the testing phase. Most likely it will be in the next release. Best, Ge! _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Robin Davies wrote:
.... Although .net manages to get by without resizable arrays. Not that I think that's a good idea; but, as language features go, it's a luxury, not a requirement, as .net demonstrates.
This is an interesting point. I don't agree with the word "luxury" though because we could use the same argument to get to an extreme and say that everything beyond Assembly is luxury ;) However, it is true that sometimes too many features may not be desired, if adding these features damages something else... If we get the array but can at the same time not use them and everything stays the same, why not? I am not an expert on how new features can change important language "core" parts, but for example the fact that SC3 separates sclang and scsynth, brings the side effect that you cannot program the dsp part (the synthDefs) algorithmically. Instead you have to deal with the buses and nodes hack. This is IMHO not desirable. Some people call this separation "a cleaner design" but I prefer the complete integration that chuck has. JPa.
participants (7)
-
Atte André Jensen
-
Ge Wang
-
Juan-Pablo Caceres
-
Kassen
-
Michael Heuer
-
Peter Todd
-
Robin Davies