On 18-Aug-2015 16:19, Andrei Alexandrescu wrote:
On 8/18/15 2:55 AM, Dmitry Olshansky wrote:
On 18-Aug-2015 01:33, Andrei Alexandrescu wrote:
On 8/17/15 2:47 PM, Dmitry Olshansky wrote:

Actually one can combine the two:
- use integer type tag for everything built-in
- use pointer tag for what is not

But a pointer tag can do everything that an integer tag does. -- Andrei

albeit quite a deal slooower.

I think there's a misunderstanding. Pointers _are_ 64-bit integers and
may be compared as such. You can use a pointer as an integer. -- Andrei


Integer in a small range is faster to switch on. Plus comparing to zero is faster, so if the common type has tag == 0 it's a net gain.

Strictly speaking pointer with vtbl is about as fast as switch but when we have to switch on 2 types the vtbl dispatch needs to be based on 2 types instead of one. So ideally we need vtbl per pair of type to support e.g. fast binary operators on TaggedAlgebraic.

--
Dmitry Olshansky

Reply via email to