Please stop polluting D 2.0 with C/C++ programmer assumptions.

Aziz K. aziz.kerim at gmail.com
Sat Dec 1 03:23:47 PST 2007


Walter Bright wrote:
> 1) The C style array declarations have been in D since day 1 :-), they  
> aren't a problem to support in the compiler, and are essentially under  
> the radar. And I know from experience that they really do help in  
> translating C code to D.
C style array decls are easy to parse. C style function pointers were a  
bit harder to parse though. I think the main problem with C style function  
pointers is that they make the D grammar ambiguous. For example:
void foo() {
   // A pointer to a function taking an integer and returning 'some_type'.
   some_type (*p_func)(int);
   // In the following case precedence must be given to a CallExpression.
   something(*p); // 'something' may be a function/method or an object  
having opCall overloaded.
   // An actual example from my D Lexer:
   isascii(*p) || decodeUTF8();
}
// Things are a bit different outside of the function scope.
// As functions can't be called at module scope we can ignore  
CallExpressions:
// A pointer to a function taking no parameters and returning 'something'.
something(*p);



More information about the Digitalmars-d mailing list