|
| multiple inheritance bug |
 |
Tue, 26 Sep 2006 23:40:31 +000 |
I have been looking at the internals of Atlas client script
(http://www.manuelabadia.com/blog/PermaLink,guid,c59facc0-301e-4e30-898d-4280388
28dcd.aspx) and I have noticed that it is designed to support multiple
inheritance. However, multiple inheritance is not working.
For example, a call to a base method using callBaseMethod doesn't work. The
reason is:
When a class that inherits for more than one class is registered, the _baseType
property is an array containing the class names. However, when callBaseMethod is
called, the method to call is obtained calling the getBaseMethod method, that
expects _baseType to have a type, not an array.
Also, the initializeBase method accepts only an array to set the parameters of
the parent class, and it should accept an array of arrays in order to work
properly with multiple inheritance. The method _callBaseConstructors has to be
changed as well to pass the proper parameters to each base constructor.
Are there any plans to fix this?
Regards,
Manuel Abadia
http://www.manuelabadia.com
|
| Post Reply
|
| Re: multiple inheritance bug |
 |
Wed, 27 Sep 2006 10:16:21 +000 |
hello.
well, it's been a long time since i've looked at the OO portion of atlas.
however, if i'm not mistaken, you can only have one base class. though i might
be wrong, i think that the array you mention is used to manage the base classes
hierarchy. i hope i'm wrong :)
|
| Post Reply
|
| Re: multiple inheritance bug |
 |
Wed, 27 Sep 2006 10:58:13 +000 |
Luis,
take a look at this Microsoft page (point 5.1.3 Multiple Inheritance):
http://start.com/developer/atlasruntime.aspx
The implementation seems to confirm this although it doesn't work.
Regards,
ManuelAbadia
http://www.manuelabadia.com
|
| Post Reply
|
| Re: multiple inheritance bug |
 |
Wed, 27 Sep 2006 13:05:34 +000 |
hello Manuel :)
well, 2 things:
1. isn't that related with gadge development? live.com (which i believe is the
latest and official version) has its own api (which i believe is based on an old
atlas version)
2. regarding multiple inheritance, i've taken a peek at the code. the current
implementation has a problem, which makes using multiple inheritance almost
impossible: passing arguments to the base class! currently, you have no way of
saying how those arguments are passed to the base classes: you just call the
initializeBase method and then everything gets passed to the base classes. it's
impossible though, as you'll see in the following example. let's suppose you
have 2 classes: Pessoa and Dados. both receive one parameter each (nome and
idade). with the current code, your base constructors (of each class) will get
allways the same 1st value from the constructor.
You can solve this if you use a convention, but again, this will make building
your classes harder and the programmer that's using it must understand the
convention used. here's a small sample that does indeed use multiple inheritance
and shows the type of conventions that may be used in these scenarios (btw, note
that i haven't even thinked in the cases where you have 2 base classes with the
same internal fields and/or properties!):
Type.registerNamespace( "Curtas" );
Curtas.Pessoa = function( nome ){
var _nome;
if( typeof(nome) == "string" ){
_nome = nome;
}
else{
for( var i = arguments.length -1; i >= 0; i-- ){
if( arguments[i].name ){
_nome = arguments[i].name;
break;
}
}
}
this.get_nome = function(){ return _nome; }
this.set_nome = function( nome ){ _nome = nome; }
}
Curtas.Pessoa.registerClass( "Curtas.Pessoa" );
Curtas.Dados = function( idade ){
var _idade;
if( typeof( idade ) == "number" ){
_idade = idade;
}
else {
for( var i = arguments.length -1; i >= 0; i-- ){
if( arguments[i].age ){
_idade = arguments[i].age;
break;
}
}
}
this.get_idade = function(){ return _idade; }
this.set_idade = function( idade ){ _idade = idade; }
}
Curtas.Dados.registerClass( "Curtas.Dados" );
Curtas.Composto = function( nome, idade ){
Curtas.Composto.initializeBase( this, [{name: nome}, {age:idade}] );
}
Curtas.Composto.registerClass( "Curtas.Composto",
[Curtas.Pessoa,Curtas.Dados]);
var t = new Curtas.Composto("kk", 12);
alert( t.get_nome() );
alert( t.get_idade() );
so, in conclusion, i really do think that multiple inheritance is not supported
in ATLAS. btw, this is a very interesting topic (at least, that's what i think).
if you have more ideas on this, please share with us (i think this is a good
topic for a new blog post :))
|
| Post Reply
|
| Re: multiple inheritance bug |
 |
Wed, 27 Sep 2006 13:45:39 +000 |
Luis,
AFAIK, the current version of Atlas can be used to create live.com gadgets.
if virtual inheritance is supported (the only place that talk about it seems to
be the URL I pointed above) it's buggy, but I am not sure if it will be
supported or even if there is some support in the implementation it will not be
supported.
As I said in my initial post, callBaseMethod doesn't work with multiple
inheritance and the initializeBase needs to take an array of arrays in order to
work with multiple inheritance. So, at the moment if multiple inheritance is
supported it isn't working properly. But if it isn't supported, why allow an
array as the second parameter of the registerClass?
Regards,
Manuel Abadia
|
| Post Reply
|
|
|