Declaration syntax

Tobias Pankrath tobias at pankrath.net
Wed Jan 8 06:43:35 PST 2014


On Wednesday, 8 January 2014 at 14:13:16 UTC, dajones wrote:
>
> "deed" <none at none.none> wrote in message
> news:unsbvdjdsxtsqgfdetby at forum.dlang.org...
>> Modifications:
>>
>> 1. Swap type and name. Like Go, but return type between 
>> function name and parameter list.
>> 2. Names come first, all other annotations after. ALWAYS. 
>> Example:
>>
>>       private const(int)[] foo(const(int)[] all, int newNum, 
>> int sum) {}
>>
>>    becomes
>>
>>       foo const(int)[](all const(int)[], newNum int, sum int) 
>> private {}
>
> 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)

x : Int = 4
h = sqrt(x * x)

Is 'h' a function or is it 2? Should h change if I change x?


More information about the Digitalmars-d mailing list