slice based on base and width

"Øivind" oivind.loe at gmail.com
Sun Sep 8 03:41:13 PDT 2013


I find myself writing the following a lot:

   a[base..base+width]

to get the slice starting at 'base' of width 'width'. In verilog, 
we select members of a vector/array in three ways

   a[c :  d]   //D: a[c   .. d+1]
   a[c +: d]   //D: a[c   .. c+d]
   a[c -: d]   //D: a[c-d .. c]

Borrowing a bit from verilog, could we make two new operators, 
maybe +.. and -.. that allow us to do the same?

I could then write e.g.

   a[base+..width]

instead of the more verbose

   a[base..base+width]


More information about the Digitalmars-d mailing list