Feature Request: make void a value type
Christopher Wright
dhasenan at gmail.com
Mon Dec 3 10:09:16 PST 2007
downs wrote:
> Proposal: to allow us to treat void as a value type.
> What this would allow:
> * simplifying templates that differ between return type, i.e. static if (is(ReturnType!(C)==void)) param(); else return param();
> I write code like that all the time :(
> * Allowing sets, i.e. void[int] .. this is something many newcomers intuitively expect to work; and by rights, it should.
>
> Problems:
> * With void.sizeof being 0, void is the only type where an array has completely different properties than the original type. I'm not sure whether this really is a problem.
>
> Code this breaks:
> * None that I can see; it only seems to affect situations that would be illegal under the current spec.
>
> What do you think?
> --downs
I did have completely separate ways of proxying void methods versus
returning methods, and it was a mess. Ugliness to the core. Right now,
I'm replacing it with static ifs, which is bulky and ugly, but it avoids
rampant code duplication.
Your suggestion would simplify my code even more. I could eliminate
almost all the static ifs, as long as void.init worked.
More information about the Digitalmars-d
mailing list