Deprecate C style declerations?

Ary Manzana ary at
Thu Dec 21 04:23:07 PST 2006

Chris Nicholson-Sauls escribió:
> Should we do this?  As in cause:
> # int foo[];
> # int bar*;
> And others to issue deprecation errors.  I think it would be a good 
> idea, and shouldn't break extern(C) declarations, so long as one doesn't 
> try to mix types.  (I don't think we can mix them in the C way at all, 
> anyhow.  Haven't tried, though.)  Or else change the rules such that 
> array/pointer decoration applies to the variable and not the type -- and 
> correct me if I'm wrong about this not being the current behavior.
> # int num   ,
> #     arr[] ,
> #     ptr*  ;
> vs
> # int   num ;
> # int[] arr ;
> # int*  ptr ;
> -- Chris Nicholson-Sauls

I want this too (to be deprecated)! I want it because of an UI problem. 
If you have:

# int[] var;

You can tell the type goes from position 0 and has length 5 and the name 
has position 6 and length 3. However, in

# int var[];

the type and name are mixed. If you want to build an AST that fully 
represents a source code, including exact positions for each AST node, 
this is painful. You'd have an AST node for an ArrayType, and another 
for a Name, but... where does the ArrayType begin and end? Currently in 
the Descent plugin this information is not guaranteed to be correct in 
this kind of declarations, but yes in the former ones.

I suggest this syntax to be deprecated. The plugin would allow you to 
convert a C-style declaration to a D-declaration automatically, it's 
very easy. I have the information of the AST nodes, and where the 
delcaration begins and end, so I can do it. In fact, if you write a 
C-style declaration, in the outline view you can see it in the D-style. :-)

More information about the Digitalmars-d mailing list