gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Heads Up: ABI Change


From: Richard Frith-Macdonald
Subject: Re: Heads Up: ABI Change
Date: Mon, 14 Feb 2011 06:51:14 +0000

On 13 Feb 2011, at 22:13, Stefan Bidi wrote:

> I made the changes to NSNumberFormatter.  Can someone take a look and make 
> sure it's correct?  I went a slightly different route and simply return the 
> subclass (NSNumberFormatter10_4) all the time.  I also used the padding ivar 
> to hold the _behavior variable.  That way both classes can use it.
> 
> I'm not sure I really like this, though.  Wouldn't this break every instance 
> where NSNumberFormatter gets subclassed since the default behavior is not 
> what that subclass would expect?  Can we make a note somewhere that whenever 
> we break ABI in the future we go ahead and have all the 10.4+ code in 
> NSNumberFormatter instead of a subclass?

Sorry, my fault, I should not have said that David's idea of subclassing was a 
good one (it seemed reasonable at the time) ... I agree with Quentin's point 
and your point about using a private subclass making it very difficult for a 
developer to subclass things themselves (ie for code outside the library).

We do actually have perfectly good practices in place for preventing ABI 
breakage, worked out over a long time (but probably not documented other than 
in emails and assorted comments scattered in the code).
When something looks like a good idea we should really ask ourselves why we 
don't normally do it that way ... usually there's a good reason.

Anyway, for existing classes, there should already be a pointer in the public 
interface which we can/should use to refer to some memory where new ivars are 
stored, and for new classes we should only ever put a single ivar in the public 
interface (unless we are copying a case where Apple explicitly expose instance 
variables using @public, in which case we would copy that).
The code in NSURLRequest.[hm] is probably a good example of 'best practice' for 
implementing a new class to avoid ever needing to break the ABI with instance 
variable changes.

So, I've updated the NSNumberFormatter code to revert to the original instance 
variable layout and use the pointer to store the extra data.  Please could you 
have a look at what I did for -copyWithZone: in particular, as I actually added 
some extra code there (it didn't appear to be copying the _locale and 
_formatter) and I'm not sure I did that correctly.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]