• 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: subclass overwriting superclass ivar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subclass overwriting superclass ivar


  • Subject: Re: subclass overwriting superclass ivar
  • From: vincent habchi <email@hidden>
  • Date: Wed, 26 May 2010 15:10:58 +0200

Le 26 mai 2010 à 14:53, Graham Cox a écrit :

>
> On 26/05/2010, at 10:41 PM, vincent habchi wrote:
>
>> Hmmm... Let's say you have a class A with a private variable "priv" and b a pointer to a subclass of A. Is:
>>
>> [(A *)b priv]
>>
>> legal?
>
>
> No. It's not legal syntax for accessing an ivar in any case - square brackets invoke a method:- [instance method].

Granted. I assumed there was a getter defined. That's because, AFAIC, I almost always synthesize ivars, so they become regular attributes.

> Perhaps you could ask is:
>
> (A*)b->priv legal?

Yes. Indeed.

> Depends. If priv is @private it is invisible to code other than within the methods of class A itself, so if this code lived inside such a method it would work, otherwise it would not. I don't think the cast makes any difference.

So, tell me if I'm wrong, but I infer from your answer that whatever I can do, there is no means for a subclass A' to access any private variable of its ancestor.

> But this is not getting to the problem that the OP is having, which AFAICS is unrelated to @private. @private is a Good Thing™ - often worth using.

Well, as a regular Python code writer, I've never missed @private (or even @protected) declarations. I fail anyhow to grasp the relevancy of @private vis-à-vis @protected: It seems logical to me that subclasses be granted access to all ancestor attributes.

Vincent_______________________________________________

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: subclass overwriting superclass ivar
      • From: Jens Alfke <email@hidden>
    • Re: subclass overwriting superclass ivar
      • From: Graham Cox <email@hidden>
    • Re: subclass overwriting superclass ivar
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >subclass overwriting superclass ivar (From: "email@hidden" <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: vincent habchi <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: Graham Cox <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: vincent habchi <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: subclass overwriting superclass ivar
  • Next by Date: Re: subclass overwriting superclass ivar
  • Previous by thread: Re: subclass overwriting superclass ivar
  • Next by thread: Re: subclass overwriting superclass ivar
  • Index(es):
    • Date
    • Thread