Re: Confusion
Re: Confusion
- Subject: Re: Confusion
- From: Jim Rankin <email@hidden>
- Date: Mon, 25 Jun 2001 11:47:39 -0400
Haven't read all the replies to this yet, but just want you to know this
post indicates to me that you are on the right track.
Having to deal with pointers to your objects, as opposed to just working
with the objects more "directly", is purely anachronistic, as far as I
can tell. Remember, Objective-C is nothing more than just enough
additional syntax on top of C to support proper OO design. Java does
away with pointers (in reality, every object reference is a pointer, but
Java does not reveal this implementation detail in the language syntax
itself). Java is an existence proof that an OO language need not have
explicit pointers in the language.
An advantage of Objective C being a C superset is that you have more
control over how things like memory allocation, etc., if you really know
what you're doing. (You can also really muck things up.) Also, you can
use existing C and C++ code without too much extra effort (much easier
than with Java, I think).
-jimbo
On Sunday, June 24, 2001, at 01:51 PM, email@hidden wrote:
Thanks to all who responded to my questions concerning the "*" and how
it is being used. However, I am now more confused than ever! Indeed,
I am so hamstrung by what appears to me to be contradictions in the
various answers, AND conflicting information in the alleged
documentation that I feel like I've taken one step forward and
five-or-six back. My level of befuddlement is so high that I can't for
the life of me even compose another question that might help clarify
the concepts I must be missing. For example, in the C textbook I have,
"The Art and Science of C" by Eric Roberts, the discussion on pointers
begins on page 454, where he states:
"In C, pointers serve several purposes, of which the following are the
more important:
Pointers allow you to refer to a large data structure in a
compact way. "
He then goes on to expand on this and offers three more "important"
reasons for pointers in C. For now I'm just trying to grasp this first
purpose and my problem is this: It was my understanding that one of
the prime raisons d'etre of Cocoa, and OOP in general, was to
encapsulate the bloody data in an object so that you didn't have to
deal with this pointer stuff. Why do I need an address "shorthand"
for a large data structure when I already have a better "shorthand" in
the form of an object that contains the data? Perhaps part of the
problem is that the word "pointer" is being used to describe too many
things that happen to be loosely related. Someone said that everything
is a pointer, or rather every object. Unless the definition of pointer
is extremely loose, this makes no sense to me at all. It tells me
nothing! Indeed, it smacks of tautology.
If I declare:
NSString *myName;
I am stating that myName is of type NSString. So, in a loose sense
myName is pointing to NSString. But the important thing here, IF I
understand this, is that I'm statically typing myName to NSString to
give the compiler a heads up so that it can perhaps find an error that
might have been missed if I just declared myName thus:
id myName;
If I have this right, then it seems to me that calling myName a
"pointer" only dilutes the definition of "pointer" when the word is
being used to describe something that is much more TO THE POINT.
I fully understand the need for a pointer in straight C to "refer to a
large data structure in a compact way," but I just don't get this need
in Objective-C when the data is within an object. I thought the idea
was to ask the object to do something with its data and return an
answer. No doubt I'm missing something here, but once again the
cryptic nature of programming documentation that seems to be de rigueur
is driving me nuts. That and the fact that most of these _teachers_
writing these expensive books I have don't seem capable of teaching
compulsive gamblers how to lose money. Memory is now cheaper than
dirt, so why are we still clinging to the overly cryptic, abbreviated,
and acronym-riddled constructs of the past? I'm just trying to control
a STUPID machine; it should not be this hard to do so!
Brian E. Howard
Cocoa Cult Central
back to square minus six!
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev