• 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: Inheritance and Loaded Libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inheritance and Loaded Libraries


  • Subject: Re: Inheritance and Loaded Libraries
  • From: has <email@hidden>
  • Date: Thu, 28 Oct 2004 14:37:36 +0100

Paul Berkowitz wrote:

1. I don't think that a script object's parent can be an application. I think it can only be another script, or AppleScript.

A script's parent property can hold any type of object. When a script object receives a command it doesn't understand, it forwards that command to the object stored in its parent property. This is called 'delegation'. Delegation is a more powerful, flexible tool than inheritance for composing objects as it doesn't suffer the same restrictions as inheritance does, e.g. inheritance can only be used to compose classes whereas delegation can compose objects of any kind.



This said, as far as AppleScript goes, it's not that useful to put anything other than the AppleScript object or other script objects into a script's parent property. The language lacks features such as operator overloading and optional parameters that would make it useful for extending built-in types such as lists and strings (e.g. to add delete and sort commands to lists). And the AppleScript compiler's reliance on 'tell application "NAME"' blocks when compiling source code containing application-defined keywords makes putting the application object for a scriptable application into the parent property more trouble than it's worth (which isn't much to begin with). So except for object-oriented programming, where the parent property is genuinely useful (virtually essential, in fact), it's best to KISS and ignore it.



HTH

has


p.s. The title of this thread is a bit misleading, since the AppleScript language - being prototype-based instead of class-based - doesn't support inheritance. Nor has any need to, since delegation can do everything inheritance can - and more.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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
  • Follow-Ups:
    • Re: Inheritance and Loaded Libraries
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Excel 2004 Scripting Block
  • Next by Date: How to find current user?
  • Previous by thread: Re: Inheritance and Loaded Libraries
  • Next by thread: Re: Inheritance and Loaded Libraries
  • Index(es):
    • Date
    • Thread