Get rid of isInfinite()?

Roman D. Boiko rb at d-coding.com
Mon Jun 25 23:10:29 PDT 2012


On Tuesday, 26 June 2012 at 03:40:11 UTC, Mehrdad wrote:
> On Monday, 25 June 2012 at 23:03:59 UTC, Jonathan M Davis wrote:
>> If you can somehow figure out how to do that via buffering, 
>> then you could make it a forward range as well as whatever 
>> other range types you could define the functions for, but 
>> you'd have to figure out a way to define save.
>
> OK, now we're at the same place. :P
>
> What I'm saying is, I __CAN__ get the buffering to work.
>
> What I __cannot__ figure out what to do with is 'length'... I 
> can't think of anything reasonable to return, since it's not 
> infinite (which I might represent as ulong.max, if anything) 
> but it's unbounded.
>
>
> So the _ONLY_ problem I'm running into right now is length() -- 
> any ideas how I could fix that?

You should decide what is length **conceptually** in your 
abstraction. In a similar situation I might want to create a 
forward range, and add indexing or slicing if they are needed. Or 
create a forward range of arrays, each representing a buffer. Or 
specify that semantically length is allowed to increase if some 
condition / predicate is true (the user might pass this predicate 
if needed).

There are many options possible, important is what use cases you 
target and what intuitive associations to already existing 
concepts you would like your users to apply.


More information about the Digitalmars-d mailing list