A few simple syntactic proposals
Tomasz Sowinski
tomeksowi at gmail.com
Thu Apr 17 06:23:52 PDT 2008
Bill Baxter Wrote:
> The argument is that 'length' is a "stealth keyword".
> It's not an official keyword, but you can't really use it for variable
> names because they'll conflict with that implicit 'length' inside brackets.
>
> Just using $ always for slicing solves that since $ is never a legal
> variable name. Besides, do we really need two ways to do exactly the
> same thing? I've never used "length" in indexing in D because I'm never
> sure what it's going to do (many of my structs have a length property to
> mimic built-in arrays -- if I say foo[0..length] in a method of that
> struct which 'length' will it use?), and because $ is a lot less to type.
>
I totally agree - I expect short names inside [..], like i, j, k, maybe "min", but "length" is just ugly and you somehow stop noticing it's a slice - the squared brackets start to look so small if you have something that big inside.
array[3..$] should be the only way.
Tomek
More information about the Digitalmars-d
mailing list