Jump to content

Call a function: Difference between revisions

m
→‎{{header|Factor}}: minor edits for clarity
m (→‎{{header|Factor}}: fixing formatting)
m (→‎{{header|Factor}}: minor edits for clarity)
Line 980:
 
* Variable arguments are achieved by defining a word that takes an integer, and operates on that many items at the top of the stack:
<lang Factor>"a" "b" "c" 3 narray</lang>
! { "a" "b" "c" }</lang>
 
* The named arguments idiom is to define a tuple, set its slots, and pass it to a word:
Line 994 ⟶ 995:
* First-class context: this pushes a word to the stack. Use execute to evaluate.
<lang Factor>\ foo</lang>
Additionally, you can put words directly inside sequences and quotations for deferred execution:
<lang Factor>{ foo } [ foo ]</lang>
 
Line 1,003 ⟶ 1,004:
<lang Factor>\ foo primitive?</lang>
 
* Factor makes no distinction between subroutines and functions. Presumably, a subroutine is just a word which puts nothing on the stack. However, if one thinks of words as taking a stack and returning a stack, then there are no subroutines in Factor.
 
* By value or by reference is irrelevant; Factor is not applicative.
1,827

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.