Why, in AppleScript, can't you declare references to variables local to handlers?

前端 未结 1 588
被撕碎了的回忆
被撕碎了的回忆 2020-12-20 03:39

Why can\'t you declare and use references to variables unless the variable referenced is scoped globally? Please explain the runtime memory or object structure that leads t

相关标签:
1条回答
  • 2020-12-20 04:34

    Because a “reference” is the same thing as an object specifier, so you can’t make a reference to something that isn’t (or is contained by something that isn’t) an object as far as AppleScript is concerned.

    A global variable is owned by the top-level script object -- it’s really a property with no initializer. (You can also have a reference to a script property; it doesn’t have to be strictly global.)

    A local variable, on the other hand, is owned by the call frame of the handler that it’s in, and call frames are not objects in AppleScript, therefore, no references.

    0 讨论(0)
提交回复
热议问题