• 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: Object inheritance question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object inheritance question...


  • Subject: Re: Object inheritance question...
  • From: "Mark J. Reed" <email@hidden>
  • Date: Tue, 27 Sep 2005 20:43:00 -0400

What you're describing sounds like prototype-based inheritance rather
than class-based inheritance.  It's not the usual O-O paradigm, but
it's very much a valid one, and certainly qualifies as "object
oriented".  It's how JavaScript works, for instance.   There's a layer
of indirection via the function object used to initialize the object,
which is conventionally considered the object's "class" and does a
good job of faking it, but JS isn't really class-based:


function Foo() { }
Foo.prototype = [1,2,3]
f = new Foo();
f.length -> 3
f[0] -> 1
Foo.prototype.bar = 'baz'
f.bar -> baz

On 9/27/05, Matt Neuburg <email@hidden> wrote:
> On Tue, 27 Sep 2005 15:25:53 +0200, Brennan <email@hidden> said:
> >There is an important difference, often mentioned when describing OOP,
> >between an "is a" and a "has a" relationship.
> >
> >A cat *is a* mammal, a dog *is a* mammal, so they both inherit milk glands
> >from the mammal class. (Mammal in turn descends from the Vertebrate class
> >etc.)
> >
> >A street "has a" house, it does not make sense to 'go for a walk down the
> >house', so it's not conceptually right for the house class to inherit from
> >the street class. In this case we would say that the street *contains*
> >some houses. A house is an *element* of a street, not a special kind of
> >street.
> >
> >House (like garage, shed and skyscraper) might more usefully descend from
> >the 'building' class.
> >
> >We might also imagine a 'one way street' class, or a cul-de-sac (or
> >whatever that's called in US English) descending from the 'street' class.
> >
> >The problem is that AppleScript uses the ambiguous word 'parent' for
> >inheritance, which is often (conceptually) used to denote 'container' as
> >well as 'ancestor'.
>
> The real problem is that AppleScript tries to pretend it's doing "is-a" when
> in fact it's doing "has-a". Every script object has a parent property and it
> uses this as a delegate when you refer to a top-level entity. The automatic
> delegation messaging is cute but there isn't really any OOP going on here at
> all because there are not really classes (despite the use of the term
> "class" as a property name).
>
> Hamish Sanderson has given some nice examples, along this line:
>
> script s
>     property parent : {1, 2, 3}
> end script
> class of s -- script
> count s -- 3
> item 1 of s -- 1
>
> So s is able to delegate "count" and "item" to its parent; but s is in no
> sense itself a list. It simply has a list that it does some delegating with.
>
> Because of this I almost changed the term "inheritance chain" to "delegation
> chain" in the new edition of my book, but in the end I decided it wasn't
> worth it. m.
>
> --
> matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
> A fool + a tool + an autorelease pool = cool!
> AppleScript: the Definitive Guide
> <http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
>
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>


--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Object inheritance question... (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: multiple text delimiters
  • Next by Date: Re: multiple text delimiters
  • Previous by thread: Re: Object inheritance question...
  • Next by thread: Re: Object inheritance question...
  • Index(es):
    • Date
    • Thread