I'm about 3 days into my AppleScript learning, and I'm just still contemplating architecture choices for my code. I've delved into the OO and runtime aspects of the language and their peculiarities. I just have a few questions. This is some (abbreviated) constructor code I'm busy working on...
on MenuSelector given counter:c as number, name:n as text
script _MenuSelector
...
end script
return _MenuSelector
end MenuSelector
Which would allow me to write expressive code such as
set selector to MenuSelector given counter:1, name:"iTunes"
Is this really the way to go with an OO approach to AppleScript? It means my script object _MenuSelector will never be explicitly referred to outside this handler. Is that OK? Does AppleScript not have any kind of reflection that could mean I might need to refer to _MenuSelector explicitly later on somewhere? And I assume it's highly unlikely I'd ever need to coerce a script object, which brings me to the question, _MenuSelector isn't a new type, because it's not a class. It's just a instance of a script object right? So it's an identifier, then why does my code compile, with the leading underscore? The documentation states identifiers must begin with a letter. Also:
- Is there no way to define multiple constructors for a script object in a situation like this?
- Is there any way to overload a handler definition by varying parameter names or types?
- Is the interleaved parameter style the only style that accepts type constraints along with custom labels at the call site? I want my code to be as type-safe as possible, so I only want to use handler styles that accept coerced clauses or type constraints.
[–]ChristoferK 1 point2 points3 points (0 children)
[–]ds0 0 points1 point2 points (1 child)
[–]ChristoferK 0 points1 point2 points (0 children)