On 7/30/18 5:02 PM, Steven Schveighoffer wrote:
Does it make sense? Would it be feasible for the language to do this? The type system already casts the delegate pointer to a void *, so it can't make any assumptions, but this is a slight break of the type system.

One possibility to avoid typesystem breakage is to internally treat a delegate structure like this:

struct Delegate(RT, PARAMS...)
{
   RT function(PARAMS params) funcptr;
   union
   {
      void *ptr;
      immutable ubyte[(void*).sizeof] context;
   }
}

Whereby the compiler is informed that the context could just be a bunch of bytes.

-Steve

Reply via email to