isInfinite isInadequate

monarch_dodra monarchdodra at gmail.com
Tue Mar 12 10:08:09 PDT 2013


On Tuesday, 12 March 2013 at 16:41:32 UTC, Steven Schveighoffer 
wrote:
> On Tue, 12 Mar 2013 12:32:22 -0400, monarch_dodra 
> <monarchdodra at gmail.com> wrote:
>> On Tuesday, 12 March 2013 at 16:16:07 UTC, Andrei Alexandrescu
>>>
>>> Crossed my mind a few times that fresh non-infinite ranges 
>>> should be empty.
>>
>> s/should/could/
>>
>> In any case, that's a very dangerous logic to follow. 
>> Not-initialized means not initialized. At that point, the 
>> concept of empty or not empty is irrelevant, it's a wrong call.
>
> No, ranges can be initialized without a constructor.  Structs 
> are.  Classes aren't.  But a class with empty as an enum would 
> work.

Depends on your definition of "initialized" I guess. Sure, you 
can create a struct instance without a constructor. Try using a 
RefCounted!(AutoInit.No) and see what happens.

> The idea is that the ultimate underlying source of empty is an 
> enum.  Since it's an enum, it should be calculable at 
> compile-time, and it should always be false, regardless of the 
> state of the range (invalid or valid).

Yes. *empty* will always answer false. My point though is that 
it's not just because range.empty says false that the range is 
ready for use.

> The problem is whether NON-infinite ranges are empty or not.  
> Looks like there are cases where they could be non-empty.
>
> -Steve

I think that each range should be responsible for its own 
initialization semantics.


More information about the Digitalmars-d mailing list