Declaration syntax

dajones dajones at hotmail.com
Wed Jan 8 12:10:43 PST 2014


"deed" <none at none.none> wrote in message 
news:lludycbhnhjzyypowtci at forum.dlang.org...
>> Why have a function declaration take a different form than an expression?
>>
>> h = sqrt(x*x+y*y)
>> s = sin(theta)
>>
>> There's thousands of years of math behind that, we are taught that form
>> before we ever get near programming a computer.
>>
>> result = do_somthing_with(parameters)
>
>
> Your example seems to show how the functions are used, not how they are 
> declared. I'm only considering declarations and prototyping.

My point was that the form should be the same for declaration and use. It's 
more consitent / intuative that way.

I can see your point that the names would be more visable at the front of 
the declaration, but I cant honestly think that it's ever been a problem for 
me. That's what syntax highlighting and formating is for. Eg...

struct {
     pure double          sin(double x)  nothrow
     immutable double  pi
     double                  sqrt(double x)  nothrow @safe
     const(int)[]            foo(const(int)[] all, int newNum, int sum)
}

is better than...

struct {
     sqrt(x)  double(double)  nothrow
     pi  immutable double
     sin(x)  double(double)
     foo(all, newNum, sum)  const(int)[] (const(int)[], int, int)
}

imo at least,  and if the names are all highlighted in luminous green it's 
all moot then anyway.





More information about the Digitalmars-d mailing list