Declaration syntax

dajones dajones at hotmail.com
Wed Jan 8 11:21:54 PST 2014


"Tobias Pankrath" <tobias at pankrath.net> wrote in message 
news:ointgouwuqyhuoowhzej at forum.dlang.org...
> 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?

if you showed the line

h = sqrt(x*x)

to 100 people, either programmers or people familiar with algebra, how many 
do you think would say that 'h' is a variable and how many do you think 
would say 'h' is a function?

And FWIW the square root of 4*4 is 4 not 2. 




More information about the Digitalmars-d mailing list