2011/4/1 Regan Heath re...@netmail.co.nz:
On Mon, 28 Mar 2011 17:54:29 +0100, bearophile bearophileh...@lycps.com
wrote:
Steven Schveighoffer:
So essentially, you are getting the same thing, but using [] is slower.
It seems I was right then, thank you and Kagamin for the answers.
This may be slightly OT but I just wanted to raise the point that
conceptually it's nice to be able to express (exists but is empty) and (does
not exist). Pointers/references have null as a (does not exist) value and
this is incredibly useful. Try doing the same thing with 'int' .. it
requires you either use int* or pass an additional boolean to indicate
existence.. yuck.
I'd suggest if someone types '[]' they mean (exists but is empty) and if
they type 'null' they mean (does not exist) and they may be relying on the
.ptr value to differentiate these cases, which is useful. If you're not
interested in the difference, and you need performance, you simply use
'null'. Everybody is happy. :)
R
For associative arrays it certainly would be nice to be able to do
something like
string[string] options = [:];
so that functions can manipulate an empty aa without using ref.
Torarin