Re: Cocoa and dead-code stripping
Re: Cocoa and dead-code stripping
- Subject: Re: Cocoa and dead-code stripping
- From: "Clark Cox" <email@hidden>
- Date: Tue, 3 Jul 2007 09:54:25 -0700
On 7/3/07, Andre Schnoor <email@hidden> wrote:
Dirk Stegemann (Mailing-Lists) wrote:
> Hello,
>
> Am 03.07.2007 um 16:21 schrieb Andre Schnoor:
>
>> While it is possible, unused code stripping has its weaknesses, like
>> others already pointed out.
>
> I'm still not convinced that *unused code stripping* is possible in
> Obj-C, because it's simply not possible to tell "unused" and "most
> probably unused" code apart, so the "weakness" is its non-feasibility;
> just call it "risky dead local code stripping" or similar, and it's
> fine...
>
I must admit I am not familiar with the reflective capabilities of
Objective-C in detail, so I might be wrong. But other dynamic OO
languages, Smalltalk for instance, can do it (I am doing it every day,
even wrote parts of the stripper myself). Hence it should be possible.
Telling used and unused code apart is straightforward unless
non-standard method calls are employed (e.g. selectors constructed from
Strings).
The problem with this is that there is nothing "non-standard" about
constructing selectors from strings. Any Cocoa app that:
loads Nibs,
uses Cocoa Bindings,
uses Core Data,
is implicitly using Key-value coding. KVC depends on being able to
call methods (and lookup instance variables) based on strings that
need not be known at compile time.
Virtually every Cocoa program uses KVC in some way.
There will of course still remain some unused code after the stripping.
No stripper is able to tell which (theoretically) reachable code will
actually be reached during runtime.
And, in Objective-C, the "stripper" would have to assume that *any*
method was reachable (because that is true; every method is
reachable). It could, however, still strip C and C++ functions.
--
Clark S. Cox III
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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