3 ms·
I like how newer languages with a C style syntax have more readable type declaration mechanisms than C (some even Pascal-like to an extent). But I am not sure
by eterps 4y ago
I like how newer languages with a C style syntax have more readable type declaration mechanisms than C (some even Pascal-like to an extent).
But I am not sure what I would prefer in some cases when looking at these new languages.
For example doing some alloc/pointer stuff in Odin is like:
ptr := new(int)
ptr^ = 123
x: int = ptr^
free(ptr)
And in Hare:
let ptr: *int = alloc(123);
let x: int = *ptr;
free(ptr);
Which approach do you prefer, and why?
- shadowofneptune 4y agohttps://www.bell-labs.com/usr/dmr/www/chist.html https://www.bell-labs.com/usr/dmr/www/chist.html From Dennis Richie: > Declarations in C must be read in an `inside-out' style that many find difficult to grasp [Anderson 80]. Sethi [Sethi 81] observed that many of the nested declarations and expressions would become simpler if the indirection operator had been taken as a postfix operator instead of prefix, but by then it was too late to change. Apart from that choice of syntax, both examples seen equivalent.
- xigoi 4y agoI prefer `^` for pointers because it's pointy, and having it after the value because it's less ambiguous when combined with subscripts and field accesses.