D should disallow forward references

Stewart Gordon smjg_1998 at yahoo.com
Wed Aug 26 19:00:59 PDT 2009


Jarrett Billingsley wrote:
> On Wed, Aug 26, 2009 at 8:47 PM, Stewart Gordon<smjg_1998 at yahoo.com> wrote:
<snip>
>> Not quite.  For example, is
>>
>>    qwert * yuiop;
>>
>> a declaration of yuiop as a pointer to a qwert, or an instruction to
>> multiply qwert by yuiop but do nothing with the result?
> 
> It's grammatically ambiguous, but not semantically. No-op statements
> are illegal.

In D, but not in C or C++.

> Thus, it's perfectly fine to always parse this as a
> pointer decl, since the other possible parse tree is always
> semantically invalid.

As D does.

Stewart.



More information about the Digitalmars-d mailing list