[Issue 8819] void static array should have init built-in propert
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 3 19:32:32 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8819
--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2012-12-03 19:32:30 PST ---
(In reply to comment #2)
> I'm not convinced this is a good idea. void[] is supposed to be untyped data,
> and a 0 initializer is specific to some types, and not for others.
In almost cases, void[] and void[n] are used to represent *bare* memory.
Then, 0-initialized bare memory is enough acceptable concept to me.
---
The enhancement only I argue is just to add init property. That means, default
construction of void[n] should be kept invalid.
void main() {
void[1] vsa1 = (void[1]).init; // allowed by this enhancement
void[1] vsa2; // default construction should still be error
}
I think void[n] should behave as like a struct has `@disable this();`.
All structs have built-in `.init`. Therefore void[n] should also have `.init`.
---
>From a view of meta-programming, I think that all types which has run-time
representation should have .init property. It is consistent and much useful.
Example:
template isSomeCheck(T) {
enum isSomeCheck = is(typeof({
T t = T.init; // Can ignore T's constructing way.
func(t); // check whether func accepts an lvalue object typed T
func(T.init); // check whether func accepts an rvalue object typed T
}
}
After taking this enhancement, only one type which doesn't have init property
is void.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list