digitalmars.D - RFC: tagged pointer
- deadalnix (8/8) Oct 07 2014 Hi all,
- bearophile (16/20) Oct 08 2014 It can't be used for GC-managed pointers. A possible usage syntax:
Hi all, There is something that is badly needed in std.butmanip : a way to create tagged pointers. It is doable safely by checking pointer alignment and allowing for n bits to be taken for various things. This is something I want to do for ages (and need) but constantly run out of time. I think it would be useful to others as well. Would someone champion it ?
Oct 07 2014
deadalnix:There is something that is badly needed in std.butmanip : a way to create tagged pointers. It is doable safely by checking pointer alignment and allowing for n bits to be taken for various things.It can't be used for GC-managed pointers. A possible usage syntax: enum Tag1 { A, B, C, D } alias TP1 = TaggedPointer!Tag1; // Uses 2 bits. enum Tag2 { A, B } alias TP2 = TaggedPointer!Tag2; // Uses 1 bit. enum Tag3 { A, B, C, D, E } // 5 possibilities alias TP3 = TaggedPointer!Tag3; // Uses 3 bits. Alternative name "TaggedPtr". It should verify some things statically about the given enum. I wrote a tagged pointer struct in D1 to implement a more memory-succinct Trie (I think the tag was one bit, to tell apart nodes the terminate a word from the other nodes). But now I can't find the source code... Bye, bearophile
Oct 08 2014