[LLVMdev] Discussion of eliminating the void type
Dan Gohman
gohman at apple.com
Mon May 7 13:04:55 PDT 2012
On May 7, 2012, at 8:07 AM, Lyu Mitnick <mitnick.lyu at gmail.com> wrote:
> Hello all,
>
> I am willing to do "eliminating the void type" project.
Is this really a good idea? I'm not going to argue at length
about it, but it is worth thinking about.
The only practical downsides of void are when newcomers take C's
syntax for functions with no arguments a little too literally, or
when they try to create pointers to void. But these problems are
quickly caught and easily corrected.
Replacing void with {} will actually make the language more
deceptive, because if newcomers think {} is LLVM's spelling for
C's void, they might be tempted to use {}* for C's void*, and
nothing will stop them except mysterious bugs if they do
arithmetic.
On the purity side, replacing void with {} has the side effect of
emphasising an odd asymmetry in the language. Conisder the return
types of functions returning 0, 1, 2, and 3 etc. values:
0: {}
1: i32
2: {i32,i32}
3: {i32,i32,i32}
etc.
Why is 1 special-cased? Argument lists don't have a corresponding
special case, after all.
Dan
More information about the llvm-dev
mailing list