wide function pointer type

Martin Uecker ma.uecker@gmail.com
Sun Oct 10 17:44:21 GMT 2021


Am Sonntag, den 10.10.2021, 10:01 -0700 schrieb Kaz Kylheku (libffi):
> On 2021-10-10 04:32, Martin Uecker via Libffi-discuss wrote:
> > Hi all,
> > 
> > I will propose a wide function pointer type (actually
> > a wide function type) to WG14 for C23 as a common
> > type for callbacks, closures, which now require an
> > additional void pointer argument in C APIs. This
> > is intended to be compatible with ABIs with now
> > use a static chain register.
> 
> Opposed. There is nothing wrong with separate arguments
> for function pointer and context.

Noted.  Your argument sbelow all boil down to the point
that there are cases where it might not be the ideal
choice. But nobody forces anyone to use it.

Martin


> Higher level languages that interface C or are built on C
> do not agree on an exact representation for closures;
> it's not a good idea to second guess them. Many languages
> are perfectly able, in their implementations, to represent
> function callable objects of all sorts using ordinary
> pointer-sized reference values. What those values refer to
> varies quite a bit.
> 
> Callback mechanisms are often bound to OOP-style objects
> rather than closures. The same context pointer is
> associated with more than one callback.
> 
> The context argument has the right flexibility to cover
> all the situations that arise.
> 
> In some library API's, the object pointer is registered
> separately, and then other functions implicitly use it
> when invoking callbacks, so it doesn't have to be passed
> any more.
> 
> Sometimes there are multiple callbacks, but one context
> pointer, passed in one call:
> 
>    initiate_operation(arg, callback_context,
>                       get_data_fn, progress_fn);
> 
> Should there be a triple wide pointer just to roll three
> arguments into one?
> 



More information about the Libffi-discuss mailing list