Class inheritance

At an early stage in the history of AppleScript, it was observed that dictionaries were becoming large and repetitious. Several classes might share some of the very same attributes, and it seemed silly, both in the dictionary resource and in its display, to repeat the information about these attributes in the entry for each of those classes. Also, in those early days there were limits on how large a dictionary could be, so there were practical reasons for wanting to prevent unnecessary repetition.

Thus a mechanism was instituted for separating out attributes common to multiple classes. This is done by having the dictionary specify that one class inherits from another class. For example, in the Finder, there is a class item; both the file class and the container class inherit from item. This simply means that whatever properties the item class has, both the file class and the container class have also—though of course the file class and the container class might have other properties that the item class does not. The item class has a name property; therefore, so does the file class, and so does the container class. Similarly, the folder class inherits from the container class. Therefore it also inherits from item, and so a folder has a name property too. Furthermore, the container class has an entire contents property; therefore, so does the folder class. We also say that item is the superclass of file and container, and that file and container are two of its

Get AppleScript: The Definitive Guide, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.