Tom;<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
</div>In ruck, I made all UGen attributes accept lambdas (anonymous<br>
functions), which to me seems a natural extension to ChucK, but I got<br>
the same response, that it wasn&#39;t very ChucK-like. What languages<br>
besides SC allow you to do things like this?<br>
<font color="#888888"><br>
</font></blockquote><div><br>Lisp does and most things based on it so that includes Scheme which in turn means Fluxus uses anonymous functions. Fluxus might be a nice system if you want Lambda&#39;s and creative programing, it even has a (modest) extension for  sound but it&#39;s mainly OpenGL.<br>
<br></div></div>I too feel a Lambda operator would be pushing it, I&#39;m not sure we need it either.<br><br>The main issue as I see it isn&#39;t one of syntax, but one of CPU. If you do all modulations at sample rate (as this sort of link implies) and you don&#39;t use block processing (we don&#39;t) then there will be a big hit on the CPU so like many systems we use rates for modulation, we just allow them to be set in a advanced way (you could also call it a roundabout way, if you wish, but I think there are big strengths to it). Considering that this is a fairly common request I think we might still want to look into it once we get our &quot;context sensitive block processing&quot; in place (meaning we block process except where there are feedback loops involved).<br>
<br>I don&#39;t see a issue with anonymous functions in ChucK as such, aside from how a lack of a name will make it harder to later refer to them if/when we get around to editing running code. I could imagine this;<br><br>
spork ~ {<br>  while(1)<br>    {<br>    foo.output() =&gt; that.input;<br>     ms =&gt; now;<br>    }<br>  }<br><br>That has been proposed before (I forgot by whom). It&#39;s not very useful in how much time/code it saves but it doesn&#39;t look incoherent to me. Doesn&#39;t look very dangerous either.<br>
<br>More useful to me would be this;<br><br>my_ADSR @=&gt; my_filter.freq;<br><br>or, more generally;<br><br>my_ADSR.last() @=&gt; my_filter.freq; //this is where the danger starts as we&#39;ll see below<br>
<br>Or, making it yet more general and getting back to anonymous funtions something like this;<br><br>{440 + my_ADSR.last() } @=&gt; my_filter.freq;<br><br>or even to pay due to the typesystem to some small degree;<br><br>
{return 440 + my_ADSR.last(); } @=&gt; my_filter.freq;<br><br>This would create a anonymous function that would implicidly be pulled whenever my_filter is ticked. Still seems somewhat coherent to me, syntax-wise, but it&#39;s aproaching the edge. While it can be debated whether any of this is &quot;ChucKian&quot; I do think that having the option of having the UGen graph pull values from some type of custom structure when a given UGen is ticked fits very harmoniously into a strongly timed paradigm. This would very quickly lead to very big issues though; when such a structure would be a function and this function would attempt to advance time (as funtions can) we would have a big problem (if I were the VM I&#39;d simply give up at that point). Basically this is inserting code into the UGen graph which is the very last place where we want ChucK code in a normal sense of the word as ChucK code typically does the type of thing that we don&#39;t want done there, like change the graph or advance time.<br>
<br>Maybe most coherent and safe would be allowing to extend UGen in our own classes, then allow for assigning UGens to UGen member functions and have those functions tick these UGens. This would mean that a custom class extending UGen would need to have a special type of function of type float called &quot;tick()&quot; and that inside of &quot;tick()&quot; we aren&#39;t allowed to advance time. Also; no linking/unlinking of UGens. Probably the only calls that we should be able to make would be to read from variables and maybe from other UGen members because if we allow function calls those functions in turn might try to do Bad Things. This is quite a easy place to do Bad Things in.<br>
<br><br>Yours,<br>Kas.<br><br>