byKey and byValue: properties or methods?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jan 18 05:29:48 PST 2012
On Tue, 17 Jan 2012 19:02:03 -0500, Nick Sabalausky <a at a.a> wrote:
> "Alvaro" <alvaroDotSegura at gmail.com> wrote in message
>>
>> Oops. Yes, thanks.
>>
>> So, not bad. In those [infrequent, I'd say] cases needing an array one
>> would do:
>>
>> auto keys = array(aa.keys);
>>
>
> My thoughts exactly. The current .keys made sense back in the days before
> ranges, std.algorithm, etc, but not so much anymore. Vote++
There is one significant problem with changing aa.keys to be a lazy range
instead of an array. This is valid code (and does exist in the wild):
foreach(k; aa.keys)
{
if(shouldRemove(k))
aa.remove(k);
}
This would silently start crashing programs if we changed the behavior of
keys.
I don't see any way around this...
-Steve
More information about the Digitalmars-d
mailing list