Cyclone Scheme  0.28.0

◆ load_varargs

#define load_varargs (   var,
  args_var,
  start,
  count 
)
Value:
list var = ((count) > 0) ? alloca(sizeof(pair_type)*(count)) : NULL; \
{ \
int i; \
object tmp; \
if ((count) > 0) { \
for (i = 0; i < (count); i++) { \
tmp = args_var[start + i]; \
var[i].hdr.mark = gc_color_red; \
var[i].hdr.grayed = 0; \
var[i].hdr.immutable = 0; \
var[i].tag = pair_tag; \
var[i].pair_car = tmp; \
var[i].pair_cdr = (i == ((count)-1)) ? NULL : &var[i + 1]; \
} \
} \
}

Variable argument count support

This macro is intended to be executed at the top of a function that is passed 'var' as a variable-length argument. 'count' is the number of varargs that were passed. EG:

  • C definition: f(object a, ...)
  • C call: f(1, 2, 3)
  • var: a
  • count: 3

Argument count would need to be passed by the caller of f. Presumably our compiler will compute the difference between the number of required args and the number of provided ones, and pass the difference as 'count'

gc_color_red
#define gc_color_red
Definition: types.h:297
pair_type
The pair (cons) type.
Definition: types.h:1247
pair_tag
@ pair_tag
Definition: types.h:64