byKey and byValue: properties or methods?

Steven Schveighoffer schveiguy at yahoo.com
Wed Jan 18 05:23:42 PST 2012


On Tue, 17 Jan 2012 19:00:38 -0500, Kapps <Kapps at notvalidemail.com> wrote:

> Is there even a point to having byKey/byValue?
> Once UFCS comes in (and there's already a seemingly working pull request  
> for it), having .keys return a range like byKey/byValue should will be a  
> silent (though more efficient) change for most programs. And in the  
> situations where it's not (namely when you want to store it as an  
> array), just adding a .array at the end would work.

It changes semantics.  For example:

foreach(k; a.keys)
{
    if(shouldRemove(k)) a.remove(k); // this is currently valid
}

-Steve


More information about the Digitalmars-d mailing list