On Fri, 22 Oct 2010 13:22:19 -0400, Stewart Gordon <smjg_1...@yahoo.com> wrote:

On 22/10/2010 03:44, Rainer Deyke wrote:
<snip>
A 'void' function returns, therefore it conceptually returns a value.
For generic programming, it is useful to treat 'void' as a type like any
other, except that it only has one possible value (and therefore encodes
no information and requires no storage).  If this is not implemented in
D at the moment, it should be.

I've sometimes thought about this, and felt in any case that void.sizeof ought to be 0.

The problem now is that it would clash with void array slicing and pointer arithmetic, which rely on the size of void being 1.

I proposed earlier that maybe you shouldn't be able to create void arrays directly. This would help with the "contains pointers" issue. Maybe we can combine that with your idea, and void * is simply a vehicle to pass untyped data, and you can only use it if you cast it to something else?

It would require a *lot* of changes to the runtime, but it might be worth it.

-Steve

Reply via email to