• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Garbage collector vs variable lifetime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage collector vs variable lifetime


  • Subject: Re: Garbage collector vs variable lifetime
  • From: "Hamish Allan" <email@hidden>
  • Date: Mon, 9 Jun 2008 23:55:06 +0100

On Mon, Jun 9, 2008 at 7:39 PM, Chris Hanson <email@hidden> wrote:

> It is perfectly legal to return an NSMutableArray from a hypothetical
> +(NSArray *)array method.
>
> However, all the sender of that +(NSArray *)array message can know is that
> the result can be treated as an NSArray.  It can't know whether an NSArray
> or NSMutableArray is returned (unless it does extra work, like using
> -isKindOfClass:, which also happens to be fragile).

Sure. But it gives you *more* information than if it just returns
"id". I agree with you in all other respects of your post, but I don't
agree that +[NSArray array] returns "id" because if it returned
"NSArray *" you'd have to have a separate declaration for
+[NSMutableArray array]. Indeed, that line of reasoning leads to
John's way of thinking: that if you return something more specific
than "id", it is in some sense indicative that the returned object is
more likely to be of a specific class, rather than a subclass thereof.

Hamish
_______________________________________________

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

  • Follow-Ups:
    • Re: Garbage collector vs variable lifetime
      • From: Charles Srstka <email@hidden>
References: 
 >Garbage collector vs variable lifetime (From: Quincey Morris <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Chris Hanson <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: John Engelhart <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Chris Hanson <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: John Engelhart <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Chris Hanson <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: John Engelhart <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Chris Hanson <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: "Hamish Allan" <email@hidden>)
 >Re: Garbage collector vs variable lifetime (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Handle mouse event (click) in CALayer sublayers
  • Next by Date: Re: Need help parsing a large text file one line at a time
  • Previous by thread: Re: Garbage collector vs variable lifetime
  • Next by thread: Re: Garbage collector vs variable lifetime
  • Index(es):
    • Date
    • Thread