Is void* compatible with function pointers?
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 23 15:00:06 PDT 2014
On Mon, 23 Jun 2014 17:16:04 -0400, Chris Williams
<yoreanon-chrisw at yahoo.co.jp> wrote:
> 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.
>
> 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.
That shouldn't work, even for an explicit cast.
It currently is deprecated, not sure what version it will be removed (I
didn't know it ever worked in the first place!)
-Steve
More information about the Digitalmars-d
mailing list