Call a function: Difference between revisions

m
m (Added the Sidef language)
Line 1,763:
 
If f is a function and c b a ares objects :
<lang Oforth>ca b ac f</lang>
will push c then b then a on the stack then call f. Calling f does not describe if f will use 1, 2 or 3 arguments (or none).
 
Line 1,771:
Intepreter will replace this second syntax by the first one. It is only "sugar"...
 
<lang Oforth>ca b ac f
ca b f(ac)
ca f(ab, bc)
f(a, b, c)</lang>
 
Line 1,779:
 
Methods need a receiver (the object on which the method will apply and the object that will pushed on th stack when self is used into the method body).
The receiver must be on the top of the stack before calling the method. If ca, b, ac and r are objects and m a method :
<lang Oforth>ca b ac r m</lang>
will call m with r as its receiver.
It is also possible to use the same "sugar" notation used by functions :
<lang Oforth>r m(a, b, c)</lang>
 
1,015

edits