D vs Go in real life

Chris wendlec at tcd.ie
Wed Dec 4 03:23:34 PST 2013


On Wednesday, 4 December 2013 at 11:12:00 UTC, Chris Cain wrote:
> On Wednesday, 4 December 2013 at 10:33:02 UTC, eles wrote:
>> http://blog.golang.org/gos-declaration-syntax
>>
>> but they give a nice convoluted counter-example; read this:
>>
>> int (*(*fp)(int (*)(int, int), int))(int, int)
>
> Yep. Spiral reading on this:
>
> fp is a pointer to a function taking in ( a pointer to a 
> function taking in an int and another int returning an int ) 
> and an int returning a pointer to a function taking in an int 
> and an int returning an int.
>
> Although it's an artificially really complex example, it's 
> ridiculous you have to read it in a spiral to understand it.

C's

int numbers[];

is really awkward. But I think that D's

int[] numbers;

is just as clear as Go's right-to-left declaration. I think the 
problem is not really the reading _direction_ but the reading 
_logic_ that makes clear what belongs to what. int[] is an array 
of integers, just as []int is an array of integers. It's clear 
because it's glued to the type and not to the variable name.


More information about the Digitalmars-d mailing list