Re: Why the need for the id type?
Re: Why the need for the id type?
- Subject: Re: Why the need for the id type?
- From: Half Activist <email@hidden>
- Date: Wed, 20 Jun 2007 08:17:45 +0200
If you consider Objective-C's roots lies in C, an instance of a class
in somewhat like an allocated struct,
as you know it's a pointer.
How could you create a C array if object's weren't memory
allocations? I suppose the language would have allowed this
but the full compatiblity with C wouldn't have been as
straightforward as it is.
In Java, although everything is actually a pointer, you don't have
access to it, and
in Java, the Object root class is there to define the methods common
to all objects and the associated behaviors.
I mean, this certainly made the creation of the vm/compiler much easier.
To me, id is only a hint you give to the compiler to make it
accept the object related syntax on a pointer.
But we can still say this is useless with one root class.
History has made Objective-C tightly bound to NS* but Objective-C is
only a language, you can define your
own classes from scratch, do the allocation etc... and also there is
the Object class.
Because just as with C, you can write a program in Objective-C that
does NOT depend on *step/cocoa.
On Jun 18, 2007, at 10:46 PM, Wagner Truppel wrote:
Hi everyone,
I apologize if this isn't directly related to Cocoa, but I suddenly
realized that I don't understand why id should be necessary. Why
isn't NSObject (or some other root class) enough? In java, for
instance, all objects inherit from Object. In a very real sense, as
far as I can see, that is essentially equivalent to full dynamic
typing. And, sure enough, you have dynamic binding, polymorphism,
and introspection (though it's somewhat annoying to work with it in
java).
I don't remember when or where from, but I once heard it said that
Cocoa couldn't be completely done in java. I don't see why not. In
any case, that's not the main reason for my question. My question
is really about understanding what is so important or different
about id that makes it necessary.
Oh, and, yes, I have read Apple's pdf on Objective-C. :)
Thank you in advance.
Wagner
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden