DekGenius.com
[ Team LiB ] Previous Section Next Section

5.4 Object-likeness

In many computer languages, values are things that you talk about. In AppleScript, values are things that you talk to. The following is a legal way to add 4 and 5 in AppleScript:

tell 4
        get it + 5
end tell

The use of tell (we are addressing the number 4), get (we are ordering the number 4 about), and it (which means "whoever I am now addressing") shows the nature of the idiom. It is not actually necessary to talk this way; one can add 4 and 5 by saying something much simpler:

4 + 5

But this works because, behind the scenes, AppleScript is supplying the tell and the get for you, to make your life simpler. In AppleScript, whether you know it or not, you are always talking to some value and telling it to do something.

One might therefore suppose that AppleScript is an object-oriented language and that all values in AppleScript are objects. Perhaps, one thinks, AppleScript will turn out to be like Smalltalk, where "everything is an object." AppleScript also has certain values that are explicitly called "objects," and refers to the datatypes of all values as "classes." Plus, in a couple of areas AppleScript implements a kind of "inheritance" between one object (or class) and another. All of these things add to the impression that AppleScript might be object-oriented.

Personally, I remain doubtful as to whether AppleScript is really an object-oriented or even an object-based language. Apple's own documentation says flatly that it is, but I've come to think of AppleScript as merely having values with certain object-like aspects. Perhaps the reason for the object-likeness of AppleScript's values has something to do with the fact that AppleScript is all about sending messages (Apple events) to scriptable applications (Section 4.1). Having devised a syntax for representing this message-sending architecture in an English-like way, AppleScript's inventors seem to have generalized this syntax to pervade the language.

    [ Team LiB ] Previous Section Next Section