• 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
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclass


  • Subject: Re: Subclass
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 15 Jun 2003 15:55:36 -0500

On Sunday, June 15, 2003, at 02:32 PM, Dustin Voss wrote:
On Saturday, June 14, 2003, at 05:01 PM, Chris Hanson wrote:
These are nonsensical in a true object-oriented language; since you can send any message to any object at any time, there is and can be no enforcement of protection.

Why ever would you think that a "true" OO language should not -- and *can* not -- have protected/private methods? Smalltalk is not the end-all and be-all, you know.

Smalltalk may not be the be-all and end-all of programming languages, but in quite literal terms it is the *definition* of object-oriented.

If you want enforcement of protection, it is up to the receiver of a message to enforce it at run time. Some Smalltalk implementations actually have a "sender" metavariable like the "self" and "super" metavariables that refers to the sender of a message in a method and can be used for just this purpose.

I don't think this would be an unreasonable extension to the Objective-C language, though it would (a) break a ton of existing code since the signature to objc_sendMsg() and every individual method would have to change to support it -- framework versioning could help here; (b) slow things down slightly because it would require an additional argument to be passed to every single method; and (c) be tricky to work out exactly what should happen in the case of forwarding (especially in the context of DO).

Now, maybe you're not really asking for true enforcement of protection. Maybe you're just asking for the ability to declare methods as being @protected or @private and then have the compiler issue a warning (if possible) when you try to send the corresponding message in an inappropriate context. That would be acceptable since it wouldn't represent a fundamental corruption of the language in the way that true protection enforcement would. It would just be a compile-time hint to developers just like static typing, not a hard restriction like it is in other languages like C++ and Java, and therefore wouldn't get in the way like it does in those languages.

Don't get me wrong. I think there are plenty of things that could be improved about Objective-C -- Smalltalk sets the bar quite high, and while Objective-C gets a lot closer than C++ or Java, it's still got a ways to go. There are even some things that could be improved about Smalltalk. The way to improve Objective-C is *not* to try to turn it into C++ or Java, but rather to try to bring it even closer to Smalltalk.

(Off the top of my head: Support for unloading & reloading classes, much cleaner category semantics, true class variables, blocks, true metaclasses, language-level exceptions rather than setjmp/macro exception handling, garbage collection, support for UTF-8 source files...)

-- Chris

--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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: Subclass
      • From: Eric Wang <email@hidden>
References: 
 >Re: Subclass (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: IB framework not compatible with Obj-C++ ?
  • Next by Date: Re: Category loading (or absence thereof)
  • Previous by thread: Re: Subclass
  • Next by thread: Re: Subclass
  • Index(es):
    • Date
    • Thread