Hi,

I'd like to break the Pepsi ABI while we still can, and add an integer
argument count to _imp_t, changing it from:

typedef oop (*_imp_t)(oop _thunk, oop receiver, ...);

to:

typedef oop (*_imp_t)(oop v__closure, oop v_stateful_self, oop v_self, int 
argc, ...);

For now, if the number of arguments supplied to the closure is
unknown, the implementation would set the argc parameter to -1.  Next,
Jolt at least could pass the correct value for argc when it sends
messages.

The next stage would be to patch GCC so that it provides an integer
macro for the number of variadic arguments supplied to a variadic
macro, and update the _send macro to use it, something like:

/* This macro is redefined by GCC within variadic macros to be the
   number of variadic arguments.  We provide a default here in case
   GCC does not yet support this extension. */
#define __VA_ARGC__ (-1)

#define _send(MSG, RCV, ARG...) ({              \
  oop _r= (RCV);                                \
  struct __closure *_c= _libid_bind((MSG), _r); \
  (_c->method)((oop)_c, _r, _r, __VA_ARGC__, ##ARG); \
})

So, sometime down the road (when the GCC patch trickles down to the
masses, or the Coke C99 parser implements __VA_ARGC__), functions will
be able to know how many arguments they were supplied, and code
defensively or throw errors if they received argc=-1.

If you agree with this design, I would be more than happy to implement
it and submit the relevant patches.

-- 
Michael FIG <[EMAIL PROTECTED]> //\
   http://michael.fig.org/    \//

_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc

Reply via email to