bitkeeper-scm / little-lang

The Little Programming Language
http://www.little-lang.org
215 stars 18 forks source link

allow for aggregate adornments to be attached to the type rather than the identifier #5

Open HalosGhost opened 8 years ago

HalosGhost commented 8 years ago

In C, arrays must be defined like so:

int arr [length];

However, pointers are declared with the * adorning the type and not the identifier:

int * ident;

For pointers, this means that the type-cast associated with the type declaration is symmetric, but the same is not true for arrays:

(int * )something; // looks just like `int * something;`
(int [] )something; // does not look like `int something [];`

Java—perhaps the only syntactical addition Java made that I like—added the ability for the [] to be specified immediately following the type:

int [] something;

Supporting both syntaxes allows people to choose whichever they find to be most expressive and helpful for the circumstance. It also might make hash declarations much clearer (imho):

int {string} some_hash;