Eduard;<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;"><br>
My question, actually, should have been about polymorphism and not inheritance. What I want is that &nbsp;having a base class Point and another class Point2D which inherits from Point, that I can define a Point &nbsp;p, that could morph and become a Point2D. Or in other words, that an UGen, can become a SinOsc.<br>

<br>
Is that possible?<br>
<br>
</blockquote></div><br>Well, the thing is; You can assign a SinOsc to a object of type UGen because a SinOsc is a UGen. However, a UGen object doesn&#39;t have a .freq() member function so you can&#39;t use that with it, even though a SinOsc (which does have that function) has been asigned to it.<br>
<br>Let&#39;s take a practical example;<br>----------------8&lt;-----------<br>UGen u;<br><br>if (maybe) new SinOsc @=&gt; u;<br>else new Gain @=&gt; u;<br><br>//so far so good<br><br><br>//here comes trouble;<br>440 =&gt; u.freq;<br>
--------------8&lt;----------------<br><br>That last line is the trouble-maker; it adresses a UGen and at that point we&#39;re not sure that UGen has that function, hence the parser objects. That line may well be valid but we don&#39;t know this for sure.<br>
<br>What I think you may need is a new class that can generate modulation signals, then extend that for various behaviours. This won&#39;t work like a UGen but you could connect it using a &quot;dummy&quot; Gain UGen in the parrent class that might serve as a output. How you&#39;d do that in practice would depend on the exact scenario, for a extremely general case this could become somehwat lengthy and involved. For a extremely basic frame-work see below.<br>
<br>Yours,<br>Kas.<br><br>--------------8&lt;-------------------<br>//this will parse. It may or may not be the kind of thing you are after.<br>//clearly a lot more infrastucture is needed<br><br>class Modulator<br>&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; Gain out;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>class Foo extends Modulator<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; ADSR env =&gt; out;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>class Bar extends Modulator<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; Envelope env =&gt; out;<br>&nbsp;&nbsp;&nbsp; }<br><br>Modulator m;<br>m.out =&gt; SinOsc s =&gt; dac;<br>
<br>new Foo @=&gt; m;<br>-----8&lt;----------------------<br><br>ps; you&#39;ll be fighting the type system. Typically fighting the type system leads to bug-reports. If it&#39;s 4am and you&#39;re throwing the keyboard against the wall do considder that you may be right and ChucK might be wrong.<br>