Skip to main content

2-1: Terms

Terms are the syntactic particles of BushelScript programs. Terms defined in dictionaries have names. Every term has a syntactic role, a semantic URI, and contains a dictionary which can define more terms.

See also: Quick Tutorial.

Term names#

Each term defined in a dictionary has a name used to refer to it. Syntactically, a term name consists of one or more words separated by whitespace and other word-breaking characters. Term names are automatically normalized by the parser by removing leading and trailing whitespace, and replacing any whitespace between words with a single space character. For example, the parser normalizes both  term name  and term   name to term name.

Syntactic roles#

Each term has a syntactic role, which determines its function.

Term roledefine syntaxSyntactic function
TypetypeCan create a type object or a variety of specifiers.
PropertypropertyCreates a property specifier.
ConstantconstantEvaluates to a constant object representing itself; models symbolic constants or AppleScript "enumerators".
CommandcommandInvokes a command.
ParameterparameterAssociates an argument with a parameter in a command invocation.
VariablevariableRefers to stored data; usually defined using a let expression.
ResourceresourceRefers to an imported resource.

Semantic URIs#

Each term also has a semantic URI, which identifies its runtime meaning. As usual, a URI consists of scheme:identifying-data. The scheme determines which data values are allowed and how they are interpreted at runtime.

URI schemes#

SchemeDescriptionData formatExample URIs with this scheme
idBushelScript native identifier (dervied from qualified term name)Any number of term names separated by colonsid:variable name
id:My Library:my type:my property
resResource IDSee resource typesres:library:My Library
res:system
res:app:System Preferences
res:appid:com.apple.Safari
ae4Four-byte AppleEvent code4 MacRoman charactersae4:cwin
ae8AE event class code, AE event ID code8 MacRoman charactersae8:coresetd
ae12AE event class code, AE event ID code, AE parameter code12 MacRoman charactersae12:coresetddata
asidAppleScript user identifierAny valid AppleScript user identifierasid:an_applescript_handler
asid:AnAppleScriptHandler

Term IDs#

A term ID is a combination of a term role and a semantic URI. Term IDs are used in contexts where multiple types of terms might happen to share the same URI (usually, but not always, with the ae4 scheme).

Overlapping terms#

Two or more terms overlap each other if they have the same name, ID, or both.

Synonyms#

Overlapping terms with the same ID but different names are synonyms of each other. Replacing a term with one of its synonyms yields no change in program behavior.

4 -- Can be any expression.
(sqrt that) = (square root that) --> true

The result is always true because sqrt and square root have identical semantics; they are synonyms.

Homonyms#

Overlapping terms with identical names but different IDs are homonyms of each other. Such identical-looking terms with different behavior should be avoided if possible. Note that homonyms are necessarily defined in different dictionaries, since a dictionary accessibly maps a name to at most one term.

Identical terms#

Terms from different dictionaries that overlap in both name and ID are identical terms. Identical terms can be used interchangeably like synonyms, but unlike homonyms, they cause minimal confusion. However, they might not have the same dictionary.

Raw form#

Raw form is special syntax that creates an anonymous term by stating its syntactic role and semantic URI inline. Terms created this way have the same syntactic function as any other term of their role.

This example refers to a term that's already defined (displayed with its usual name at runtime):

#type [ae4:cwin] --> window

#type [ae4:abcd] is a not typically a defined term, but raw form can construct it on the fly. This is useful to quickly fill gaps in AppleScript terminology.

#type [ae4:abcd] --> #type [ae4:abcd]
Last updated on by Ian Gregory