Collection Object
Ruslan Zasukhin
sunshine at public.kherson.ua
Fri Aug 4 23:10:44 CDT 2006
On 8/1/06 6:37 PM, "Philip Mötteli" <philip.moetteli at econophone.ch> wrote:
>> In C++ when I have container of Some objects casted to Parent class,
>> I can access methods and attributes only of parent classes. You
>> remember
>> this yes?
>
> No, but I know, that C++ does a lot of tinkering in order to be OO.
> Aha, that's the reason, why you constantly link inheritance with
> collections.
:-) right.
Well, this is not just C++ issue.
I am sure that REALbasic, Java, C#, work in the same way.
> It's not the collection, that cares about the type/inheritance of a
> member. It's the ObjC runtime system.
Yes.
> In ObjC, we have a generic type: id, which is actually just a pointer
> to the very basic skeleton, that every object has:
>
> typedef struct objc_object {
> Class isa;
> } *id;
>
> typedef struct objc_class *Class;
>
> struct objc_class {
> struct objc_class *isa;
> struct objc_class *super_class;
> const char *name;
> long version;
> long info;
> long instance_size;
> struct objc_ivar_list *ivars;
> struct objc_method_list **methodLists;
> struct objc_cache *cache;
> struct objc_protocol_list *protocols;
> };
Cool here is that in ObjC you have this structures open. In C++ there is no
such description of what is internally...
> The compiler creates for every method call of some object the
> following function call:
>
> objc_msg_send(someObject, method,);
>
> This function then looks up the concrete method using
>
> someObject->isa->methodLists
>
> populates it with the arguments, by reading out its signature.
And this happens always. This explains why ObjC is slower of C++
Such lookup will be slower of virtual method access in C++,
which is just access of array element by index.
> In order to do all that, the compiler has to pack a lot of runtime
> information about the objects and their methods into the program. And
> it is exactly that runtime information, that also allows me to write
> my transparent persistence layer.
I see.
> To cut a long story short: A collection object doesn't need
> inheritance. It only needs a format constant member indication and
> dynamic binding (that is the dynamic dispatching of these methods).
Well, I can say this is just the maximal generalization of idea.
1) Collection of the same types -- e.g. arrays in C
2) Collection of objects of different type but with the same PARENT class,
we have this in C++ C# Java, RB, ...
3) ObjC have made step future - and allow put into collection absolutely
everything ... Payment for this is that EACH class is RTTI class, and each
its method is virtual, and even worse than virtual.
Clear.
> I think it is better like this:
>
> if(table(Table_ID)->hasField('name'))
> doQuery
>
> Is the better approach.
I have think exactly about the same thing, Philip :-)
start:
* We take Oid,
* go to record pointed by it:
this bring us to some table T
we ask this table if it have field we need
if yes - do search there
if no - go to start
--
Best regards,
Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc
Valentina - Joining Worlds of Information
http://www.paradigmasoft.com
[I feel the need: the need for speed]
More information about the Valentina
mailing list