On Wednesday, March 12, 2025 12:07:04 PM MDT Manfred Nowak via Digitalmars-d-learn wrote: > On Tuesday, 11 March 2025 at 16:56:28 UTC, WhatMeWorry wrote: > [...] > > To include the upper bound value, use a square bracket "]" at > > the end of the range." > > [...] > > foreach( i, e; a[0..3] ) > > write(i, ":", e); // 0:11 1:22 2:3 > > That example negates the claim of that Citation already! > > Although a square bracket follows the range "0..3", neither the > index '3´ nor the value of 'a[3]´ are remarked---and are not > written indeed.
In mathematics and computer science in general, it's very common in the notation of ranges / intervals of numbers to use ] at the end of the range of values when the last number is inclusive, and ) when it's exclusive. So, I could definitely see some of the documentation using such notation when explaining things (though I don't recall seeing that anywhere off the top of my head). However, it definitely isn't something that's a syntactic part of how D handles anything. As Ali mention, it looks like std.random does use [ and ) in strings used as template arguments to specify the behavior of some functions, but that's probably the closest that we actually have to it being part of the language itself. So, I don't know what part of the documentation that WhatMeWorry read which gave him the impression that the language itself uses ] or ) in any of its syntax to indicate how open an interval is, but it implies that either something we have was not written clearly enough (which is very possible) or that WhatMeWorry misinterpreted it in an unusual way. - Jonathan M Davis