As D lacks a lexical specifier for class reference types there is currently no way to determine the size of a class instance at compile-time. A simple solution would be to add a new property, valid for pointer and reference types, that evaluates to the size of the referenced type. Thus:
(byte*).isizeof == byte.sizeof == 1
(byte**).isizeof == (byte*).sizeof == 4 (on 32-bit systems)
byte.isizeof == Error: property isizeof is only valid for reference types.
MyClass { int x, y; }
MyClass.isizeof == 8
(MyClass*).isizeof == MyClass.sizeof == 4 (on 32-bit systems)
Multiple levels of indirection can be eliminated using recursive templates, so there is no reason to collapse multiple levels of indirection and return the size of the final referenced type.
Comment #1 by sean — 2006-04-06T19:15:26Z
Walter Bright wrote:
> [email protected] wrote:
>> Severity: enhancement
>
> Please don't add feature requests to the bug list.
I thought you'd suggested adding the "pending peeves" to the bug list.
Sorry.
Sean
Comment #2 by kylefurlong — 2006-04-06T19:15:29Z
Walter Bright wrote:
> [email protected] wrote:
>> Severity: enhancement
>
> Please don't add feature requests to the bug list.
What else is the enhancement severity for?
Comment #3 by sean — 2006-04-06T19:20:21Z
Kyle Furlong wrote:
> Walter Bright wrote:
>> [email protected] wrote:
>>> Severity: enhancement
>>
>> Please don't add feature requests to the bug list.
>
> What else is the enhancement severity for?
Eh, I think Walter wants to maintain a fairly high signal/noise ratio on
the bug list. That's perfectly reasonable IMO. Though it suggests the
need for a forum besides digitalmars.D for proposals and such, as things
tend to get lost fairly quickly there.
Sean
Comment #4 by kylefurlong — 2006-04-06T23:55:35Z
Sean Kelly wrote:
> Kyle Furlong wrote:
>> Walter Bright wrote:
>>> [email protected] wrote:
>>>> Severity: enhancement
>>>
>>> Please don't add feature requests to the bug list.
>>
>> What else is the enhancement severity for?
>
> Eh, I think Walter wants to maintain a fairly high signal/noise ratio on
> the bug list. That's perfectly reasonable IMO. Though it suggests the
> need for a forum besides digitalmars.D for proposals and such, as things
> tend to get lost fairly quickly there.
>
>
> Sean
How is any "noise" added to the "signal" you want? The point of those filters is that you can ignore then ones you want to.
Comment #5 by sean — 2006-04-06T23:55:37Z
Kyle Furlong wrote:
>
> How is any "noise" added to the "signal" you want? The point of those
> filters is that you can ignore then ones you want to.
I have no idea. I'll stop guessing now :-)
Sean
Comment #6 by bugzilla — 2007-08-02T03:39:19Z
The __traits(classInstanceSize, classname) added to 2.003 provides this functionality.