A function call in Guile is very cheap: the VM simply hands control to the procedure. The procedure itself is responsible for asserting that it has been passed an appropriate number of arguments. This strategy allows arbitrarily complex argument parsing idioms to be developed, without harming the common case.
For example, only calls to keyword-argument procedures “pay” for the cost of parsing keyword arguments. (At the time of this writing, calling procedures with keyword arguments is typically two to four times as costly as calling procedures with a fixed set of arguments.)
If the number of actual arguments is not
<= expected, respectively, signal an error.
The number of arguments is determined by subtracting the stack pointer
from the frame pointer (
fp - sp). See Stack Layout, for more
details on stack frames. Note that expected includes the
NONE comparison result
values if the number of arguments is respectively less than, equal to,
or greater than expected.
NONE comparison result
values if the number of positional arguments is respectively less than,
equal to, or greater than expected. The first nreq
arguments are positional arguments, as are the subsequent arguments that
are not keywords.
are used to implement multiple arities, as in
See Case-lambda, for more information. See Branch Instructions,
for more on comparison results.
flags is a bitfield, whose lowest bit is allow-other-keys, second bit is has-rest, and whose following six bits are unused.
Find the last positional argument, and shuffle all the rest above
ntotal. Initialize the intervening locals to
SCM_UNDEFINED. Then load the constant at kw-offset words
from the current ip, and use it and the allow-other-keys
flag to bind keyword arguments. If has-rest, collect all shuffled
arguments into a list, and store it in nreq-and-opt. Finally,
clear the arguments that we shuffled up.
The parsing is driven by a keyword arguments association list, looked up
using kw-offset. The alist is a list of pairs of the form
(kw . index), mapping keyword arguments to their
local slot indices. Unless
allow-other-keys is set, the parser
will signal an error if an unknown key is found.
Collect any arguments at or above dst into a list, and store that list at dst.
Ensure that there is space on the stack for nlocals local
variables, setting them all to
SCM_UNDEFINED, except those values
that are already on the stack.
alloc-frame, but doesn’t check that the stack is big enough,
and doesn’t initialize values to
SCM_UNDEFINED. Used to reset
the frame size to something less than the size that was previously set
Equivalent to a sequence of
allocate-frame. The number of locals reserved is expected