From: herring@smaug.uio.no (B. Erickson Herring)
Newsgroups: comp.object
Subject: Re: Can C++ / X empower us to make great apps for the 90's?
Date: 12 Apr 92 02:01:19 GMT
	<1992Apr8.060832.9260@sfc.sony.com> <jctic0k@fido.asd.sgi.com>
	<1992Apr11.021508.29048@ux1.cso.uiuc.edu>
In-reply-to: mlanett@void.ncsa.uiuc.edu's message of 11 Apr 92 02:15:08 GMT

|mlanett@void.ncsa.uiuc.edu (Mark Lanett) writes:
|
|linton@marktwain.rad.sgi.com (Mark Linton) writes:
|>I agree that interface builders are a good thing and the Next one
|>is quite nice.  I believe that dynamic loading is the important feature
|>missing from most C++ environments; I'm less convinced that
|>I need to be able to get "method not defined for this object" errors.
|
|A friend bought a NeXT (he's an experiences MacApp/C++ developer) and
|has not been terribly impressed with NextStep. One of his biggest
|complaints is that he *isn't* getting "method not defined for this
|object". Next has their doesNotUnderstand message just swallow
|everything and not provide any error messages at all! The only way
|he's figured out to tell if a message is actually received and
|understood by the correct object is to step into every method
|dispatch. To top it off, which Obj-C allows typed objects, the Next IB
|cannot parse them; it requires everything to be 'id'. So even if he
|wants to type things to reduce a really ridiculous number of runtime
|errors... he can't.  Maybe 3.0 will be better.

I absolutely must take issue with this, though I have not read the entire
thread.  Please be advised that I am only responding to what I think are
some misperceptions on the part of Mark's friend.

The fact that one does not receive a "method not defined" message is the
expected, and, IMHO (always IMHO :-), correct behavior.

If an inappropriate message is sent to a smalltalk object, that message is 
passed up the chain, all the way to Object.  If it is not implemented
anywhere in the chain, what happens?  A walkback dialog, of course.  What is
this the equivalent of in smalltalk's compiled cousins?  A crash, or at 
least an exception.

In smalltalk, the environment helps you out.  In ObjC, the programmer is
required to take prophylactic measures on his own behalf, and I quote the 
relevant material from the NeXTstep documentation:

---- From the NeXTstep Reference Manual, Version 2 ----
---- OnLine as Object.rtf in:                      ----
/NextLibrary/Documentation/NextDev/NextStep/Reference/02_Classes/CommonClasses

Among other things, the Object class provides its subclasses with a
framework for creating, initializing, freeing, copying, comparing, and
archiving objects, for performing methods selected at run-time, for
querying an object about its methods and its position in the
inheritance hierarchy, and for forwarding messages to other objects.
For example, to query an object about what class it belongs to, you'd
send it a class or a name message.  To find out whether it implements
a particular method, you'd send it a respondsTo: message.
                                     ^^^^^^^^^^^
---- End ----

The point here is that the programmer is responsible for determining if an
object responds to a method _before_ sending it that method.  This is 
conceptually quite tidy, and has the benefit of encouraging the programmer
think before messaging.

To address Mark's second point, concerning IB(Interface Builder)'s
requirement that everything be of type id:

Nothing is stopping any programmer from using "#ifdef DEBUG" in her/his
code.  What this means in this case is:

#import <something.h>

@interface
 {
  #ifdef DEBUG
   Matrix myMatrix;
  #else
   id myMatrix;
  #endif
 }


And so on.  Now, IB will not "parse" this code properly, but then "parse"
has a very specific meaning when one is working with IB - "parse"'ing is
the means by which the programmer includes prewritten class-definitions
in an IB project.  Once the classes are "parse"'d, you can do (almost)
whatever you wish to the code.  As long as it is syntactically correct,
of course ... :-)

Erick Herring
Professional Systems, Norway

P.S.  This is being posted because I am constitutionally incapable of sitting
idly by while erroneous/misleading/incomplete information is given about the
NeXT, and because a great many people who read this group probably do not
have the ability to judge if they have received correct information vis a vis 
NeXT.  If NeXT specific things need to be discussed any further, I would be 
most happy to correspond by email.