Re: isa
Re: isa
- Subject: Re: isa
- From: Marcel Weiher <email@hidden>
- Date: Sun, 2 Jun 2002 10:23:43 +0200
On Saturday, June 1, 2002, at 11:22 Uhr, Aram Greenman wrote:
The thread where this originally came up (re. ObjC inits vs. C++
constructors) had to do with sending messages to self in an initalizer,
which is _usually_ a bad idea,
No. In Objective-C it is not "usually" considered a bad idea at all.
since it is possible the method called might access unitialized
instance variables, depending on where you are in the initializer chain.
Well, don't call methods that might access uninitialized instance
variables, then! ( "Doctor, doctor, it hurts when I bang my head
against the wall")
Setting isa temporarily to the class which defines the -init would
protect against this. (Personally I just avoid sending messages to self
in an init or at least comment their use, but anyway.)
A dangerous "cure" to a non-existent problem.
However, it could potentially be useful in other cases. Dynamic typing
and binding allow us to say [fredAstaire dance] and [mcHammer dance]
and get two different behaviors. Of course you can get along w/o
dynamic typing/binding, but no one on this list, at least, would _want_
to. 'isa-swizzling' could allow us to say, for example, [fredAstaire
danceLikeMCHammer]. Of course there are other (complicated) ways to
accomplish the same idea, but this seems like a more elegant solution.
"Seems" is the operative word here.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
- Follow-Ups:
- Re: isa
- From: Aram Greenman <email@hidden>
References: | |
| >Re: isa (From: Aram Greenman <email@hidden>) |