Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective C-- and multiple inheritance [OT]



At 9:32 PM +0100 2/27/02, Thomas Engelmeier wrote:
And the whole point of Obj-C is the (compiler supported) addition of a COM dispatch table,

You keep saying this, and it's not true. COM is nothing more than a standardized C++ virtual function table format on Windows.

Windows, MacOS (CFPlugin, CodeWarrior) and (similar, with minor differences) in Java.
You're sure the dispatch table is laid out differently in ObjC? (That means that each bridged object in the ObjC<->Javabridge costs a huge proxy object..)

QueryInterface doesn't buy you the kind of dynamism Objective-C includes natively. Also, Objective-C existed well before COM did.

Why not? What exactly does it do I cannot do by querying if there is a special interface?

In Objective-C, when you send a message to an object, it gets resolved at run time.

OK, standardized dispatch table plus a Stringmap with method signatures?

If I want to use "add( 5.0f )" with all Java objects _that support it_ in a C++ list, I might use an approach like

typedef std::list<boost::shared_ptr<CJavaObject> > JObjList;
JObjList myList;
jmethodid theMethod;
CJavaObject *theObject;

[... fill the list]

jfloat theValue = 5.0;
for( JObjList::iterator it = myList.begin(); it != myList.end(); ++it )
{
theObject = it->get();

theMethod = theObject->findMethod( L"add(f)" );
if( theMethod )
theObject->callVoidMethod( methodID, theValue );
}

which boils down a bunch of lines more but - where please is the CONCEPTUAL difference?
If I want to send a message (i.e.: use an message interface) - why shouldn't I use an similar approach?
It is just not built in.

In C++, even virtual function calls are mostly static; they're just a double-indirect through a table rather than a straight jump. And the offset into the virtual function table is recorded at compile time, not determined at run time.

Jepp. Single indirect, btw. Speeeeeeeeeed advantage?

bizarre semantics for some compiler - supported reflection API,

In a true object-oriented language -- one that's built on dynamic messaging -- there's nothing at all "bizarre" about being able to ask an object whether it responds to a particular message. Also, again, it happens at run time, not compile time.

Not the possibility, the semantics are bizarre.
[anObject paramName:value paramName2:value2];

- in natural languages ';:,-!?' divide semantic distinct parts. In ObjC they _glue together_
- in natural languages an ' ' is the separator between word belonging together, In ObjC it separates distinct things.
- in a natural language you'd say "with this do that" or "let this do that".
The representation "anObj->doIt();" is not really perfect, but in "[anObj doIt];" is just a bunch of words, collected together with [], with no indication what their "role" is.

It's not really possible in Standard C++. To get these features in C++, you need [...]

Nope. You need to write a whole bunch more, but it is possible. I use such a method to "reflect" an XML exported and bound API. Still it is ugly as it is not compiler-aided...

But at the same time, it appears that some of the vocal critics of Objective-C *don't* really understand it. Please, learn the language and try working with it a little bit before criticizing it as "disgusting,"

I simply see nothing - not even a small project - that'd gain if I'd learn ObjC. Given that, to add the models I own to the "wc" WebCam drivers I probably'll have to learn ObjC and backport it to C++ - I prefer to use my drivers also on OS 9.

"inappropriate for anything but rapid prototyping" (which is absolutely *not* the case),

I consider dynamic linked stuff, that is not at least checked at startup, inappropriate for shipping (and later, debugging) an app. It is simply not feasible to completely test it. So it makes nice prototypes and weekend projects.

"bizarre," etc.

See above. The semantic is pretty much like "klick Start to Stop the operation of your computer". Doesn't stop others to belive Windows is wonderfully designed, though..

Regards,
Tom_E
--
Thomas Engelmeier * Quark Solutions GmbH / Munich, Germany
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Objective C-- and multiple inheritance [OT] (From: Andrew Pinski <email@hidden>)
 >Re: Objective C-- and multiple inheritance [OT] (From: Thomas Engelmeier <email@hidden>)
 >Re: Objective C-- and multiple inheritance [OT] (From: Chris Hanson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.