I’m evaluating a change to add support for “profiles” to Chrome’s dictionary. Right now we have:
application has windows
and we’d be adding:
application has profiles
profile has windows
When I build with this proposed change, aelint is not happy:
~> aelint --dynamic "Chromium"
[...]
X ERROR (2)
----------------------------------------
[...]
ambiguous-term: Term 'profile' is used by multiple codes: class 'CrPf', property 'prof'
AppleScript maps a name to one code when compiling source; multiple codes are ambiguous
What would be the best way to proceed here? The object is a “profile”, and you would also refer to a “window’s profile”. The same word is used for each, so how bad is this ambiguity?
aelint îs flagging the collision of the two definitions of the term profile: one is a class and the other is a property. AppleScript may confuse them, depending on the context in which they are used. I suggest changing the name of one or the other.
Change the property name to something other than profile: eg. active profile, current profile.
Alternatively, rename the profile class to something like window profile and retain the profile property on the window class. This allows you to have expressions like profile of window 1 which yields an instance of window profile.
I’m trying to make the AppleScript dictionary reflect the existing mental model of a user who uses Chrome, so I’m not sure how I could go in either of your proposed directions.
There is a collection of “profiles” owned by the Application; the pull request adds a “the application contains profiles and a profile contains windows” containment hierarchy, so no worries there.
The mental concept is “profile,” not “window profile.” There’s a “Profiles” menu that lists profiles:
On the other hand, we need to expose the profile that owns the window. “What’s the window’s profile?” makes sense, but “what’s the window’s active profile” or “what’s the window’s current profile” don’t make sense as they imply that a window can change a profile, which it can’t. Maybe “owning profile” but that feels very strained. Is there no way out?
In /System/Library/ScriptingDefinitions/CocoaStandard.sdef, 'docu' has the name “document” and is both a property on the window and is a class. Would using the same 4CC for “profile” and having the same name work too?
Yes, if the 4-character codes are the same, you can have a term which defines a class and a property.
AppleScript will detect the context (property reference vs class reference) during compilation and decompilation. However, do not do this when defining event parameter names - AppleScript will not always correctly detect the context (parameter vs direct object property reference).
By the way, I’m excited to see that aelint has prompted this discussion. Helping developers create great scripting interfaces for their applications was the goal of the tool.