Array Slice Ranges

Bill Baxter dnewsgroup at billbaxter.com
Wed Nov 8 23:13:39 PST 2006


Trevor Parscal wrote:
> == Quote from Walter Bright (newshound at digitalmars.com)'s article
>> I have a bit of a problem with .. vs ..., I think they both look too
>> similar  making it hard to review code for correctness, and I'd have a
>> hard time remembering which means which, another source of bugs.
> 
> Perhaps you guys aren't keen on the .. and ...
> 
> But it would be nice to have some symbol mean "through" in ranges to acompany the
> current .. which means "until"
> 
> Like..
> 
> 0 _ 5 == 0, 1, 2, 3, 4, 5
> 0 .. 5 == 0, 1, 2, 3, 4
> 
> Sorry - I know there's more important things to do.... Just puting my 2 cents in...

__ is a legal identifier though, so you'd need spaces to use it generally.

Maybe

   arr[2~~3] -- two dots stretch out and squgglified?
   arr[2**2] -- two dots gone hairy?
   arr[2::3] -- two dots .. on top of two dots ..
   arr[2``3] -- closest you can get to two dots up high
   arr[2##3] -- eh..
   arr[N@@B] -- heh heh

   Or how just put it all together: arr[2`~.@#:3]

--bb



More information about the Digitalmars-d mailing list