pelle.mansson at gmail.com
Wed May 26 05:44:15 PDT 2010
On 05/26/2010 11:44 AM, bearophile wrote:
> Andrei A.:
>> I hope to work with ranges only.<
> Programming life is complex, you can't fit all of it in one schema ("A foolish consistency is the hobgoblin of little minds").
Couldn't you just define opApply where you need it and it will be used
where foreach is used by default, anyway?
>> Will look into it, sounds like an implementation matter.<
> Yes, right. But to implement this idea the foreach() has to change a bit, to set the flag in nonrelease mode. If implemented this idea lessens a bit the need for the stable ("soft") methods.
>> Probably some trees could save some state if they exploit O(log n) length.<
> In general a length can be O(n) if for example you want to compute it on a linked list that doesn't keep the number of items inserted. Are you going to just not give a length attribute for such linked lists (so users have to use something like walkLength)?
Isn't that a good thing? If I know length is fast, I can use it without
worries, but if it might be O(n) you need to avoid it.
More information about the Digitalmars-d