Huh, invariant() {...} ?

Bill Baxter dnewsgroup at billbaxter.com
Mon Jun 18 17:00:43 PDT 2007


Henning Hasemann wrote:
> Am Mon, 18 Jun 2007 22:08:47 +0300
> schrieb "Kristian Kilpi" <kjkilpi at gmail.com>:
>
> But maybe the right approach then is not to reduce the number of
> keywords but build up a syntax that makes it always possible to
> distinguish a user-defined name from a keyword.
> 
> For example in
> 
> const invariant int const;
> 
> its clear that the last const would be the variable name even it is a
> keyword too. 

The thing Walter has responded before about such comments is that it 
makes the grammar non-context free.  The lexer has to become intertwined 
with semantic analysis to know for sure if each word encountered really 
is a keyword or not.  It's not impossible, but one of Walter's big goals 
for D is to have a simpler grammar than C++ (while at the same time 
being more productive than C++).  Having a simple grammar makes it more 
likely that external tools will be able to do a good job parsing it, and 
that anyone who sets out to implement a D compiler will have less 
trouble doing so.

--bb



More information about the Digitalmars-d mailing list