The colon notation accesses named parts (properties) of a value.
It is used to get and set fields, call methods, construct compound symbols,
and more.
Evaluating the form
evaluates the owner:property then it extracts the named owner of the result.
property
property-access-abbreviation ::= property-owner-expression:property-name
property-owner-expression ::= expression
property-name ::= identifier | ,expression
The property-name is usually a literal name,
but it can be an unquoted expression (i.e. following a ,),
in which case the name is evaluated at run-time.
No separators are allowed on either side of the colon.
The input syntax is translated by
the Scheme reader to the internal representation owner:part($lookup$ .
owner (quasiquote part))
Evaluation proceeds as follows.
First property-owner-expression is
evaluated to yield an owner object.
Evaluating the property-name yields a part name,
which is a simple symbol: Either
the literal identifier, or the result of evaluating the
property-name expression.
If the expression evaluates to a string, it is converted to
a symbol, as if using string->symbol.
If the owner implements gnu.mapping.HasNamedParts,
then the result is that of invoking the get method of the owner
with the part name as a parameter.
As a special case of this rule, if owner is a
gnu.mapping.Namespace, then the result is the
compound symbol in that namespace.
If owner is a java.lang.Class or a gnu.bytecode.ObjectType,
the result is the static member named part
(i.e. a static field, method, or member class).
If owner is a java.lang.Package object, we get the member
class or sub-package named part.
Otherwise, we look for a named member (instance member or field).
Note you can’t use colon notation to invoke instance methods
of a Class, because it will match a previous rule.
For example if you want to invoke the getDeclaredMethod
method of the java.util.List , you can’t write (java.util.List:getDeclaredMethod because that will look for a static method in java.util.List.
If the colon form is on the left-hand-side of an assignment (set!),
then the named part is modified as appropriate.
Some of these are deprecated; more compact and readable forms are usually preferred.
(instance:method-name arg ...)
(class:method-name instance arg ...)
(class:method-name arg ...)
(*:method-name instance arg ...)
For details see Method operations.
class:field-name
instance:field-name
(prefix:.field-name instance)
For details see Field operations.
expression:length
(expression:.length)