std.array suggestion
Ivan Senji
ivan.senji_REMOVE_ at _THIS__gmail.com
Thu Mar 9 06:43:09 PST 2006
Oskar Linde wrote:
> Ivan Senji wrote:
>
>> Oskar Linde wrote:
>>
>> ...
>>
>> Totally agree that something like this (and more) should be in the
>> standard library.
>
>
> Please elaborate on (and more).
>
:P I knew you were going to say that. I was just trying to say that the
new features open up a lot of possibilites. (not trying to say you
didn't to a great job, more that there is more that could be done in a
standard library)
No ideas at the moment, but when I think of something I'll let you know.
>>> Upon rereading, I realized that the inplace versions should be void
>>> functions - not returning an array.
>>
>>
>> Not sure about this one. Returning an array allows chaining:
>>
>> array.doMap(someDelegate).doSort();
>
>
> Yes, but void removes the chance of using inplace versions by mistake
> and makes it extra obvious that they are not ordinary functions. I think
> this is more important than the ability of chaining.
>
What you say does make sense. But I don't think it would be souch a big
problem. It is always safe to use ordinary array functions, and it would
be nice to be able to just replace them with inplace ones for
performance reasons if the original array is not needed any more.
So if I have:
array.map(someDelegate).sort();
and I figure out that it could be optimized because I don'n need the
original array I could just change the functions used.
But if the general consensus would be for inplace functions to return
void I would have to agree :)
More information about the Digitalmars-d
mailing list