Neat project: add pointer capability to std.bitmanip.bitfields

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 3 06:28:06 PST 2015


On 12/03/2015 07:45 AM, Steven Schveighoffer wrote:
> On 12/2/15 6:51 PM, Andrei Alexandrescu wrote:
>> On 12/02/2015 06:04 PM, ZombineDev wrote:
>>> On Wednesday, 2 December 2015 at 19:39:47 UTC, Andrei Alexandrescu
>>> wrote:
>>>> Once done, this is a fantastic example of (a) the power of generative
>>>> programming, and (b) the advantages of using library facilities
>>>> instead of built-in features.
>>>>
>>>> https://issues.dlang.org/show_bug.cgi?id=15397
>>>>
>>>> Who would want to take it?
>>>>
>>>>
>>>> Andrei
>>>
>>> So, something like
>>> http://dlang.org/phobos/std_bitmanip.html#.taggedPointer?
>>
>> Sigh, yes. Both taggedPointer and taggedClassRef should be features of
>> bitfields, not distinct names. One good thing to do would be to
>> integrate those within bitfields, and then later perhaps undocumented.
>
> taggedPointer and taggedClassRef are GC safe (despite the incorrect
> warning listed in the docs). Your proposed mechanism is not.

It can be restricted to support what tagged* do.

> IMO, we should keep those and close your enhancement, it doesn't add
> anything useful. Seems to me something that can break very easily.

Please leave it open, thanks.

> Phobos should in no way support such egregious casts implicitly. Even in
> @system code.
>
> Do you have any rationale to prefer arbitrary bitfield pointers over GC
> safe ones?

1. The less restricted version offers use of high-order bits as well. If 
we don't support that, those who need it will do that in client code 
with the usual liabilities.

2. There's no reason for taggedPointer and taggedClassRef to exist. They 
should be integrated within bitfields.


Andrei




More information about the Digitalmars-d mailing list