On Tue, Apr 17, 2012 at 08:48:04PM +0200, Andrej Mitrovic wrote: > On 4/17/12, Andrej Mitrovic <[email protected]> wrote: > > On 4/17/12, H. S. Teoh <[email protected]> wrote: > >> But even then, I'm considering if .keys should return a mutable array if > >> the key is a value type > > > > How about having .keys for mutable > > Personally I use .keys often and expect them to be mutable. For example: > > string[] atts = attributes.keys; > sort(atts); > > There is no "sorted" in phobos so I have to use the sort function > which takes arguments by reference. I can't pass immutable arrays to > it. > > Sometimes I like to store an array of keys from multiple hashes, e.g.: > string[] arr = hash.keys; > arr ~= hash2.keys; > > Long story short, making .keys immutable would break a lot of my code. > I don't know if that's true for others as well..
What if .keys returns a tail-immutable array? You should still be able to sort it, right? T -- There is no gravity. The earth sucks.
