(atsign tag) tag: a sym
Accesses a method's self-object.
(atsign sym)
is usually abbreviated
as @sym
.
atsign
is only meaningful within the body or parameter list of a method,
or the initializer form of a field, constant or
property.
In all of those contexts, there is a hidden local variable which represents the "self
object" - that is, the object which is receiving the method call, or the object which
contains the field, or the class which contains the constant, etc. @
can be used to
access that hidden local variable.
The local variable can be captured by a closure, so fn
will work as expected.
There are various symbols which have special meaning when passed to @
, such as
@base
or @self
.
Otherwise, for an arbitrary symbol name
, @name
has one of the following meanings:
-
@name
is equivalent to[@self 'name]
. It accesses a field or property on the self-object. -
(? @name)
is equivalent to[@self (? 'name)]
. It accesses a field or property on the self-object which may be absent. -
(@name arg0)
is equivalent to(.name @self arg0)
. It invokes a method on the self-object. -
((? @name) arg0)
is equivalent to((? .name) @self arg0)
. It invokes a method on the self-object which may be absent.
In a method parameter list, when a parameter's name is prefixed with @
, that method
will prefix its body with (= @name name)
, assigning the value of that
parameter to the corresponding field or property.