Is void* compatible with function pointers?

Chris Williams via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 23 14:16:04 PDT 2014


On Monday, 23 June 2014 at 20:49:27 UTC, Steven Schveighoffer 
wrote:
> Since most architectures use same-size words for function 
> addresses and object addresses, D would be fine to say it's 
> defined and valid. I think the extreme outliers are 
> architectures that are not equal, and D will not be harmed too 
> badly by making this distinction. Any D flavor that would be 
> ported to such an architecture may have to be a derived 
> language.
>
> -Steve

While it might be fine, I would be concerned that people wouldn't 
understand the difference between a function and a delegate. They 
would figure that if you can store a function reference in a 
void* then you should be able to fit a delegate in as well, and 
proceed to lose data.

I would make it something where the compiler forces you to make 
an explicit cast. Before that, it should warn you about the 
potential loss of data.


More information about the Digitalmars-d mailing list