de facto keywords

Paul D. Anderson paul.d.anderson.removethis at comcast.andthis.net
Sat Apr 5 13:20:58 PDT 2008


Robert Fraser Wrote:

> Paul D. Anderson wrote:
> > It seems to me there exist a few "unofficial" keywords in D that should be promoted to reserved words:
> > 
> > "string", "dstring", "wstring" -- I'm assuming that backward compatibility is the only reason these are not declared as keywords. Is there more to it than that?
> 
> These are aliases in the library. They have as much right to be keywords 
> as "Socket" or "printf".
> 

I'm aware they are aliases. My concern is that they are so common in the library that anyone who deliberately (or worse, ignorantly) uses them somewhere else is likely to have problems. The way to avoid these problems (IMHO) is to reserve the words. 

> > "tuple" -- The use of tuples is ubiquitous in D. There is a a "tupleof" property for structs and unions. The "foreach" keyword knows about them. Yet there is no syntactic support for the thing itself. It is confusing to be required to define a template to access something the compiler creates. This may be just syntactic sugar but it's necessary sugar, IMHO.
> 
> I agree there should be syntactic support for tuples, but I don't think 
> the "tuple" keyword is best. Instead, what about (int, float, 3) being a 
>   tuple?
> 

My personal preference is for a keyword rather than a syntactic interpretation, but I wouldn't object to the change you describe. My gripe is with the reliance on a template for access to fundamental constructs.


> > Paul
> 
> The _real_ de facto keyword is the word "length" since when it's used 
> inside an array index it shadows any variable called "length" outside.

I agree, but I can hear the screams from the populace who have used "length" all over their code. All the more reason, IMO, to make the change now.

Paul




More information about the Digitalmars-d mailing list