Declaration syntax
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Jan 7 17:24:41 PST 2014
On Wed, Jan 08, 2014 at 12:35:18AM +0000, Adam D. Ruppe wrote:
> On Wednesday, 8 January 2014 at 00:23:34 UTC, deed wrote:
[...]
> > At this point the readability and overview would be improved
> >IMO.
>
> I don't agree; I find that backwards and weird. Comes down to what
> you're used to probably.
>
> Another option might be to put tabs in there so you write
>
> void foo()
> int bar()
>
> and so on so the names are vertically aligned.
If we're going to redo syntax, we might as well adopt a much less
ambiguous (and prettier!) function declaration syntax based on
mathematical notation (which is also adopted by some functional
languages):
funcName : type1 arg1, type2 arg2, ... -> returnType
For example:
pow : real base, real exponent -> real
{
// Variable declaration
tmp1 : real;
// Variable declaration with initializer
result : real = dotDotDotMagic(base, exponent, tmp1);
// Statement as usual
return result;
}
T
--
IBM = I'll Buy Microsoft!
More information about the Digitalmars-d
mailing list