A better language
renox
renosky at free.fr
Tue Apr 18 14:23:00 PDT 2006
Chris Nicholson-Sauls wrote:
> renox wrote:
>
>> Chris Nicholson-Sauls wrote:
>> [cut interesting remark showing that automagic pointer dereferencing
>> reduce the interest of postfix pointer derefencing]
>>
>>> // your idea: x: @[10]->int;
>>> // currently: int[10]* x;
>>>
>>> Knowing that in D types are read right-to-left in declarations,
>>
>>
>> I know that and for me, this is an unpleasant pitfall of D, especially
>> for array declaration:
>> int[Y][X] t; and then t[x][y] = ...
>>
>> t: [X]->[Y]->int; and then t[x][y] = ...
>>
>> Honnestly which reads better?
>
>
> Honestly, to my eyes? The current style. I don't care for the `->`
> symbol needed in the proposed syntax,
In Pascal it was 'type: array[1,10] of int;' if memory serves which is
definitely too verbose. I like '->' that's what Scala use: it looks like
math.. But this is just a matter of taste.
> and I'm just too used (in D) to
> scanning down columns of variables and glancing (right to left) to check
> types.
That's the problem once you got used to a syntax, you don't even see its
problem anymore, as I'm not using D and that in C/C++ the array
declaration has the correct order, the inverse array declaration/usage
of D still 'hurt my eyes'.
> Probably if it had been otherwise from earlier on, my habits
> would be different, while as it is... Although I do admit to liking a
> left-to-right style in general, I just don't see a way to do it in D.
> For what its worth, a purely hypothetical pet language of me and a
> couple buddies (codename Lux) has used this for years:
>
> # {* Equivelant to D decleration "int[10]* x;" *}
> # var() {
> # &[10]int32 : x ;
> # }
Interesting, I like it. It's compact and it's clever to use & instead of *.
The terseness may make it a bit hard to read for beginners, but it's nice.
I prefer 'variable: type' than the other way round because as in Limbo
you can do this nice regular syntax:
my_var : int; // declares my_var with type int and initialise it with
default value of type int (0).
my_var : int = 5; // declares my_var with type int and initialise it with 5
my_var := 5; // declares my_var with type inferred from 5 (int), and
initialise it with 5
my_var = 6; // assign 6 to my_var, my_var must already be declared with
a compatible type.
To avoid people abusing of ':=', the language just have to forbid double
declaration of variable in the same function.
Regards,
Renaud.
>
> -- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list