I gave two above (callbacks from OS services which derive the
specific instance based on information passed as parameters in
the callback).
I see the straight-forward redefinition of the this member to be
flexible, assignable. I see the static {..} block as being a very
positive feature (as CAlive also adds angel classes which are
short-duration classes which instantiate and de-instantiate auto-
matically in context, and could be used to support dynamic features
on static calls when no instance could be identified).
I see the ability to make dynamic and static functions essentially
the same for all internal function calls, more closely mimicking
what is actually seen in the physical ABI.
It makes everything more solid in the system, which reflects more
accurately what it really is in terms of the underlying mechanics,
(classes are logical constructs relating to physical implementations),
but it also makes it more flexible because things like an on-the-fly
change of the this member would be possible:
xyz* p1 = new xyz(15); // Create with a value of 15
xyz* p2 = new xyz(10); // Create with a value of 10
p1->some_function(p2);
void xyz::some_function(xyz* p2)
{
if (p2->value < value)
this = p2;
// Now, the entire reference to this instance is the min
// of the two parameters, without having to assign to a
// separate function pointer and then being required to
// use that on every reference.
}
-----
The only issue I see would be in legacy code interfaces. The missing
parameter on static callbacks from pre-existing functions that are
not aware they're calling a class member function statically, those
would need fixups.
In those legacy cases, the compiler could auto-create a marshalling
function which handles adding the extra parameter until the API
designer can create a version which auto-adds the extra NULL
parameter for the class member function static callback.
Add the keyword "static":
CreateThread(..., static &threadHandler, ...);
^^^^^^
In those legacy cases, the compiler would then auto-inject the marshal
function which is the OS API callback target, which then directs to
the correct function with the expected parameter.
In future releases, the OS API would be updated and we'd use the new
function static class callback function, which is called directly:
CreateThreadSC(..., &threadHandler, ...);
The new function would acknowledge its callback is a static class,
and would auto-inject the extra NULL parameter for the class instance
of the static callback. This would then signal code to enter the
static {..} block to derive the runtime context.