What is the stance on partial initializers when declaring multiplevariables of the same type?
Simen Kjaeraas
simen.kjaras at gmail.com
Thu Jul 21 16:37:02 PDT 2011
On Thu, 21 Jul 2011 23:34:59 +0200, Andrej Mitrovic
<andrej.mitrovich at gmail.com> wrote:
> Well I don't know about special syntaxes.
>
> What I might have overheard was that if you do initialize in the
> declaration, the compiler might request that you specify initializers
> for all the variables. In other words:
>
> float x, y, z = 0.0; // error
> float x = 0.0, y = 0.0, z = 0.0; // ok
>
> But I don't know, this could be waay too intrusive from a low-level
> language. I think I saw someone mention they would like partial
> initializers to go away. I'm so-so with the idea, it could be too much
> trouble for any gain.
I like this. It might not be a common bug, and D has reasonable enough
defaults that it's not unlikely you will notice the problem soon, but
it has a very simple workaround (declare variables on more than one
line) and gives a very clear indication of what might be wrong.
Votes++;
--
Simen
More information about the Digitalmars-d
mailing list