Ranges

Max Samukha outer at space.com
Fri Jun 19 03:04:13 PDT 2009


On Fri, 19 Jun 2009 11:49:06 +0300, "Kristian Kilpi"
<kjkilpi at gmail.com> wrote:

>On Fri, 19 Jun 2009 03:13:11 +0300, Derek Parnell <derek at psych.ward> wrote:
>> Steve Teale (steve.teale at britseyeview.com) wrote:
>> Now I admit that these are not method names I would have choosen, as I
>> would have preferred names more like ... isEmpty(), getFront(),
>> moveForwards(), getBack(), moveBackwards(), getElement(N), addElement(E),
>> but the bikeshed gods have more wisdom than me ... and not that I'm
>> complaining of course.
>
>I agree. Well, even if the names of the Range methods are a bit 'odd' for  
>me, I guess they are ok... except for empty().
>
>If I have a container that I wan't to use as a Range, I can't use empty()  
>to empty the container (i.e. remove all the elements from it). :(
>
>And yes, *I* am complaining here. ;)
>
>I'm accustomed to use isXyz() for checking something and xyz() for doing  
>something (e.g. isEmpty() + empty()). What function name should I use for  
>emptying the container then? removeAllElements(), makeEmpty(), or maybe  
>even emptyThisContainer()...? :P

clear() is used quite often. You could use the likes of erase() or
purge(). But, as Yigal already said, ranges and containers they crawl
over are usually distinct types, so this shouldn't be a big problem.

>
>Hmm, should the Range methods use some special naming convention? E.g.  
>rangeFront(), rangePopFront()...?



More information about the Digitalmars-d mailing list