[chuck-users] Any way to call an arbitrary function with some value

George Locke george.locke.maxmsp at gmail.com
Wed Mar 11 09:12:57 EDT 2015


The LiCK library has lots of functional programming tools.
https://github.com/heuermh/lick

...
if (parameterName == “gain”) myUgen.gain (value);
... etc ...

You could write your own class where every parameter is accessed via an
associative array using a pattern like "class.set("paramName",
parameterList)"

 - George

On Wed, Feb 25, 2015 at 12:19 PM, Kassen <signal.automatique at gmail.com>
wrote:

> Hey, Rich!
>
> I’m pretty sure I know the answer to this already – its not a dynamic
>> language...
>>
>
>
> Indeed, and not a functional one either... but let's go over it anyway :-)
>
>
>> However, I can put a UGen method into a variable, but I cannot apply it:
>> ...
>> SndBuf2 input;
>> input.gain @=> Object f;
>> ...
>>
>> This compiles, but can I apply it to an argument?
>>
>>
>
> IMHO you have found a bug. I don't feel this should compile or parse;
> input.gain is a function and functions are not objects, in ChucK, and hence
> I feel the assignment should fail with some error message. I can see your
> reasoning; that if it compiles you'll want to do Useful Stuff with it, but
> IMHO this situation is the sad result of differences between "ChucK" as a
> language and the actual chuck compiler/VM.
>
>
>> Am trying to find a way of modifying arbitrary parameters via osc that
>> doesn’t include writing unmaintainable code:
>> ...
>> if (parameterName == “gain”) myUgen.gain (value);
>> ... etc ...
>>
>>
>>
> Ok, I can see how the above would look better if we had variables of type
> function. We don't have those... but your illustration here looks far from
> "unmaintainable" to me. Indeed it is a bit longer than the alternative in
> -say- Scheme, but on the bright side; if you make a typo in this kind of
> situation the parser will likely catch it for you before it compiles at
> all. That has serious benefits too in how maintainable code is.
>
> Hope that helps a bit?
>
> Yours,
> Kas.
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20150311/96678df5/attachment.html>


More information about the chuck-users mailing list