Case Range Statement ..

"Jérôme M. Berger" jeberger at free.fr
Thu Jul 9 15:13:22 PDT 2009


Andrei Alexandrescu wrote:
> Jérôme M. Berger wrote:
>>     So, the correct way to define an inclusive range is with "+1" 
>> except when it's with "nextUp", unless you're talking about the right 
>> end of the range where it is inclusive by default and the right way to 
>> make it exclusive is with "+1" except when it's with "nextUp"?
>>
>>     That's what I call consistent!
> 
> I completely disagree with your assessment. First, you didn't mention
> what the range is supposed to do. For example, what primitives should
> the range have? Are you talking about a built-in type or a
> library-defined type? etc.
> 
> There are two places in the language where expression1..expression2
> comes into play: when slicing an array, and when iterating with foreach.
> In both cases the range is discrete with step 1, and so it makes sense
> to discuss that when expression1..expression2 is being talked about. Now
> you can't just silently redefine what you mean by range and then claim
> inconsistency.
> 
> If you want to make a case, please state clearly what are you talking
> about. Nobody can be consistent with a definition that doesn't exist.
> 
	Please don't remove relevant quotations from my message. *You* were 
the one who said:

 > b+1 is correct if the range is iterated by 1, as in foreach or as an
 > array index. That's what Walter meant because that's what's in the
 > language. If you want to define a floating-point range that is 
closed to
 > the right, you may want to use an open range from a to nextUp(b). The
 > nextUp function (defined in std.math by Don I think) returns the very
 > next floating point value. That's exactly what I do in std.random.
 >


-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20090710/7519caff/attachment.pgp>


More information about the Digitalmars-d mailing list