[chuck-users] eval and concatenating strings

altern altern2 at gmail.com
Wed Nov 15 12:23:37 EST 2006


hi

Spencer Salazar wrote:
> Hi Enrike,
> 
> On Nov 13, 2006, at 9:08 PM, altern wrote:
> 
>> hi again
>>
>> here i am with couple of questions again.
>>
>> is there a way to concatenate strings? I am trying different ways with
>> no much luck and i have checked the docs but i could not find a way  
>> to it.
> 
> Not at the moment... this is a high priority on the ChucK wish list,  
> however.
> 
>> another issue is:
>> is there a way to eval a string as code like in python or  
>> actionscript?
> 
> Also not at the moment... with string operations and the also highly  
> desirable file i/o this would be somewhat possible to do, though.
> 
>> The questions come from some commands i am forced to type over and  
>> over
>> despite of being almost identical
>>
>> recv.event("/0/mute, i") @=> OscEvent mute0_osc;
>>
>> the only difference of the number (0 in this case) for each of the
>> sample players i have constructed
>>
>> Would it be possible to create variables on the fly from concatenated
>> strings?
>> I mean something like (in wish code)
>>
>> for (0 => int n; n < 8; n++){
>> 	"/" + Std.itoa(n) + "/mute, i" @=> string address; //concatenate  
>> string
>> 	recv.event(address) @=> OscEvent Std.eval("mute"+ Std.itoa(n) +
>> "_osc"); //concatenate and eval string
>> }
> 
> I think code like this is really powerful and really useful, but  
> unfortunately it sort of throws a big huge wrench into the type  
> systems of languages like ChucK.  So, to be honest, I don't see  
> something like this usage of Std.eval becoming possible in the near  
> future.

Sure, i understand that ChucK is not python. There are different tools 
for different tasks. I was just wondering if something like this would 
be possible. I am just trying to get an overview of the ChucKian way of 
thinking. I realised that some stuff is not in the documentation (maybe 
im wrong?) like Std.itoa() so I thought maybe there is other 
undocumented commands as well.

> For what it's worth, once string operations are fully implemented,  
> something resembling this will be possible:
> 
> OscEvent mute_osc[8];
> for (0 => int n; n < 8; n++){
> 	"/" + Std.itoa(n) + "/mute, i" @=> string address; //concatenate string
> 	recv.event(address) @=> mute_osc[n];
> }
> 
> This is similar to your wish code, though not as dynamic or flexible  
> of course.

sounds good enough to me.

thanks

enrike

> thanks,
> spencer
> 
>> thanks
>>
>> enrike
>>
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> 
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> 



More information about the chuck-users mailing list