
Hi, Is it possible to extend a class from two parents classes? So the child class will have the data and functions of the two parents. I am not an oriented object programming expert, but I understand (maybe I am mistaking) that C++ is able to do that. At first I wanted to do a kind of extended SndBuf UGen including and playing automatically a score. The goal is to write short code like: MySndBuf s=> dac; 120 => s.bpm; s.score << 1 << 1 << 0 << 1; // write the score "kick.wav" => s.read; while(1) 10::ms => now; // let's play I made some quick testing, this is possible. But then appears the second Idea ;-) Sequencers are really useful so why do not have a basic sequencer common for other application. For example: // the Synth frequency driver MyFreqExtendStep f => TriOsc s => dac; f.note << 40 << 42 << 44 << 0; // Write score with midi note 120 => f.bpm; while(1) 10::ms => now; // let's play // The Event automatic boardcaster (to trig other scripts for example) MyEvent e; e.score << 1 << 1 << 0 << 1; // write the score 120 => e.bpm; while(1) 10::ms => now; // let's play Happy chucking, Ju

On Thu, Oct 04, 2012 at 04:48:13PM +0200, Julien Saint-Martin wrote:
Hi,
Is it possible to extend a class from two parents classes? So the child class will have the data and functions of the two parents.
I'm sorry, but the simple answer is a plain "no that won't work". For better or (/and?) worse ChucK is a great deal more simple than C++ Sorry, Kas.

Hi Kassen,
Ok, thank you for your response.
No problem, you don't have to be sorry. I survived ten years programming
without objects so I will find an other solution ;-)
Ju
2012/10/5 Kassen
On Thu, Oct 04, 2012 at 04:48:13PM +0200, Julien Saint-Martin wrote:
Hi,
Is it possible to extend a class from two parents classes? So the child class will have the data and functions of the two parents.
I'm sorry, but the simple answer is a plain "no that won't work".
For better or (/and?) worse ChucK is a great deal more simple than C++
Sorry, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

On Fri, Oct 05, 2012 at 02:59:16PM +0200, Julien Saint-Martin wrote:
Hi Kassen,
Ok, thank you for your response. No problem, you don't have to be sorry. I survived ten years programming without objects so I will find an other solution ;-)
Personally I never felt the need to extend multiple things at once, to be honest, I tend more towards having one big object include several smaller ones. I could see how it could save on the copy-pasting and keeping track of where you copy-pasted when you edit one case. Oh, well... Kas.

That the approach I m thinking about now.
But this way (including one object into one other) constraints you to have
additional interface functions?
Ok I know my question is not clear ;-) let's illustrate it with an example:
class A{ void fun do_stuff() { /* do stuff ....*/ } }
If I want to have the same do_stuff functionality in another class, if I
extend it, I have nothing to do.
class B extends A {} // B Will automatically have the do_stuff
functionality
But if I include it, I have to do:
class B { A a; // sort of include
fun void do_stuff() {a.do_stuff();} /// This is the
additional interface I told about in my question
}
Then I will be able to do:
B b;
b.do_stuff();
Ok it s just one line of code in this example but it can be much more if
you have several functions and several class extensions.
If you feel I am lazy its true ;-) That's why I like to program, I make the
machines work for me!
Ju
2012/10/5 Kassen
On Fri, Oct 05, 2012 at 02:59:16PM +0200, Julien Saint-Martin wrote:
Hi Kassen,
Ok, thank you for your response. No problem, you don't have to be sorry. I survived ten years programming without objects so I will find an other solution ;-)
Personally I never felt the need to extend multiple things at once, to be honest, I tend more towards having one big object include several smaller ones. I could see how it could save on the copy-pasting and keeping track of where you copy-pasted when you edit one case.
Oh, well... Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (2)
-
Julien Saint-Martin
-
Kassen