[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] environments as prototypes (to know or not to know)

Hi Ron,

I suppose you could make a separate PrototypeEnvironment that checks for you (perhaps with a flag to turn it off
in performance).

I am still not sure if making extensive use of environments as prototypes is such a good idea:

The main problem is that using Environments directly, either in class libraries or in runtime interpreted code, might be broken later due to a change in the class interface (by an extension or in Common). This breakage can lead to errors that are pretty difficult to trace. There needs to be a way to at least check this. Maybe the checking method I suggested does what you propose?

1. It adds yet another layer of indirection that is not explicitly integrated into the class hierarchy, making it
tough to sort out what is going on.

2. There is the problem of collisions with the message name space of Object.

3. Keeping everything in Environments and doing the layering with 'parent' (rather than using a class wrapper) is more transparent. It also makes it possible to alter things for a specific project without having to change the class

Alberto's GUI class demonstrates the advantages of using environment prototypes: it allows you to stick to standard coding style, so it is very easy to migrate existing work into a new framework.

GUIEvent and ConductorGUI demonstrates making the environment lookup explicit.
If requires yet another paradigm (Event style coding) for the GUI.
But it integrates the 'skin'
with the GUI library and should be easier to extend.


On Aug 2, 2006, at 10:40 AM, Julian Rohrhuber wrote:

or, make a subclass of event that redefines put if you want to keep maximum speed.

 this means that ~tilde is not safe and also not
 (a: { myfunc }) style.

 another way to do it is:

 prototype {
 		var coll = this.methodCollisions;
 		^if(coll.isNil) {
 		} {
"This % cannot be used as prototype, because the following methods " "are already defined in its class definition: %\n".postf(this.class, coll);

 methodCollisions { arg coll;
this.keysDo { |key| if(this.class.respondsTo(key)) { coll = coll.add(key) } };
 		proto !? { coll = proto. methodCollisions(coll) };
 		parent !? { coll = parent. methodCollisions(coll) };

 Then you just call
 .prototype when you want to be sure.


 sc-dev mailing list

sc-dev mailing list