D's type declarations seem to read right to left.

tipdbmp email at example.com
Wed Mar 21 20:07:09 UTC 2018


D's type declarations seem to read right to left.


int an_integer;

int[10] an_array_of_10_integers;
int[10]* a_pointer_to_an_array_of_10_integers = 
&an_array_of_10_integers;

int*[10] an_array_of_10_pointers_to_integers;
int*[10]* a_pointer_to_an_array_of_10_pointers_to_integers = 
&an_array_of_10_pointers_to_integers;

int[3][2] an_array_of_2_arrays_of_3_integers;
int[string] a_hashtable_with_string_keys_and_integer_values;

int[3][string][2] 
an_array_of_2_hashtables_with_string_keys_and_array_of_3_integers_values;

int function(float) 
a_pointer_to_a_function_that_takes_a_float_and_returns_an_integer;
int function(float)[10] 
an_array_of_10_functions_that_take_floats_and_return_integers;


I think this is a big improvement over C's "spiral" way of 
reading types: http://www.unixwiz.net/techtips/reading-cdecl.html
I guess it could've been left to right, but... it's okay.



More information about the Digitalmars-d-learn mailing list