new D2.0 + C++ language

bearophile bearophileHUGS at lycos.com
Fri Mar 20 19:31:37 PDT 2009


Yigal Chripun:
> what you suggest is C++ with better syntax, *NOT* a variant of D. for that look at: http://en.wikipedia.org/wiki/Significantly_Prettier_and_Easier_C%2B%2B_Syntax

Thank you for the link, I did know only "A Modest Proposal: C++ Resyntaxed".
In some situations that SPECS syntax is more readable than D syntax:

Function having an int argument and returning pointer to float:
(int -> ^float)

Pointer to function having an int and float argument returning nothing:
^(int, float -> void)

Note that SPECS uses  ^  :=  and  =  as in Pascal.
Pointer syntax of Pascal is better, and the :=  = often avoid the C bugs like if(a = b).

But probably D needs to tell apart functions and delegates too, so that syntax isn't enough.
And I think now it's not easy to change the meaning of  ^ in D :-)

So a possibility (keeping the usual * pointer syntax):
{int => int}
Delegate:
{{int => int}}
That can also offer a syntax for anonymous functions/delegates:
{int x => x*x}
{x => x*x}
{{x => x*x}}

Bye,
bearophile



More information about the Digitalmars-d mailing list