Previous Page
Next Page

12.1. Reference as Target

It's hard to explain what a reference is. In a sense, it is simply a complete target , such as folder 1 of application "Finder". But it isn't the target "out there" in the world; it's the target as expressed in your code. This way of putting it makes a reference sound like merely an expression. But it's more than that. It's a value embodying such an expression.

To see what I mean, let's imagine obtaining such a value in a way that's very commonas a result returned by a scriptable application. Any time you fetch an attribute of a scriptable application, if the result is not a built-in datatype such as a string, it is likely to be a reference. For example:

tell application "Finder"
    set x to (get folder 1)
end tell

Now, what's x? On my machine, it's the following:

folder "Mannie" of desktop of application "Finder"

It sounds natural enough. But think a little more about this. What can it mean? What is x, really? A folder is a thing in the Finder's world. Surely the Finder cannot have literally handed this folder to our script. Rather, the Finder has handed us a way of talking about this folder, a means of access to this folder. That's a reference.


Previous Page
Next Page