Call an object method: Difference between revisions

→‎{{header|TXR}}: A few notes.
(→‎{{header|TXR}}: New section.)
(→‎{{header|TXR}}: A few notes.)
Line 1,900:
TXR Lisp method invocation syntax is <code>obj.(method args...)</code>.
 
Static methods are just functions that don't take an object as an argument. The above notation, therefore, normally isn't used, rather the functional square brackets: <code>[obj.function args...]</code>.
 
The <code>defstruct</code> clause <code>:method</code> is equivalent to <code>:function</code> except that it requires at least one argument, the leftmost one denoting the object.
 
The <code>obj.(method args...)</code> could be used to call a static function; it would pass <code>obj</code> as the leftmost argument. Vice versa, the square bracket call notation can be used to invoke a method; the object has to be manually inserted: <code>[obj.function obj args...]</code>.
 
<syntaxhighlight lang="txrlisp">(defvarl thing-count 0)
543

edits