why ; ?

Janice Caron caron800 at googlemail.com
Mon May 12 09:57:49 PDT 2008


On 12/05/2008, Leandro Lucarella <llucax at gmail.com> wrote:
>  >     foo(int x)  // Danger!
>  >     {
>  >         /* stuff */
>  >     }
>
>  Is this valid D?

I missed out the word "void". I meant

    void foo(int x) // Danger!
    {
        /* stuff */
    }

or else run the risk of being misparsed as

    void foo(int x);
    {
        /* stuff */
    }

And, yes, I'm sure you can invent some arbitrary ad hoc rule which
disambiguates in this case, but there are always going to be more
cases. I'm not the only one to have demonstrated an ambiguity which
would result from semicolons being optional. Doubtless there are many
more ambiguities lying in wait.

But I don't want to get into an endless cycle of "Here's another
ambiguity" followed by "Here's the next ad hoc rule to disambiguate".
Let's just not go there.



More information about the Digitalmars-d mailing list