|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - Implicit slice bounding
Any chance we might get the implicit slice bounding? Currently the following forms are valid: thing[] // [0, thing.length) thing[f .. t] // [f, t) I'd like it if we could also do the following: thing[f .. ] // [f, thing.length) thing[ .. t] // [0, t) The problematic part is that a simple implementation would be opSlice(T from); opSlice(T to); How would we distinguish between the two? Without having some nasty kludges, we'd probably be restricted to only one of the two extra slice operations, and I would suggest the first one would be the one most commonly required. Of course, if they'd both be commonly required (or at least it's not 1000 to 1), then it's probably best to just leave it as is. Ho hum. Although, we could have opSliceF(T from); opSliceT(T to); Thoughts? Matthew Dec 18 2003
There was a lengthy discussion regarding this a couple of weeks ago: D/19634 "Matthew" <matthew.hat stlsoft.dot.org> wrote in message news:brt4c7$1f7h$1 digitaldaemon.com...Any chance we might get the implicit slice bounding? Currently the following forms are valid: thing[] // [0, thing.length) thing[f .. t] // [f, t) I'd like it if we could also do the following: thing[f .. ] // [f, thing.length) thing[ .. t] // [0, t) The problematic part is that a simple implementation would be opSlice(T from); opSlice(T to); How would we distinguish between the two? Without having some nasty Dec 18 2003
In article <brt4c7$1f7h$1 digitaldaemon.com>, Matthew says...Any chance we might get the implicit slice bounding? Currently the following forms are valid: thing[] // [0, thing.length) thing[f .. t] // [f, t) I'd like it if we could also do the following: thing[f .. ] // [f, thing.length) thing[ .. t] // [0, t) The problematic part is that a simple implementation would be opSlice(T from); opSlice(T to); How would we distinguish between the two? Without having some nasty kludges, we'd probably be restricted to only one of the two extra slice operations, and I would suggest the first one would be the one most commonly required. Of course, if they'd both be commonly required (or at least it's not 1000 to 1), then it's probably best to just leave it as is. Ho hum. Although, we could have opSliceF(T from); opSliceT(T to); Thoughts? Matthew Dec 19 2003
davepermen wrote:what if opSlice just gets 0, or length, as first, or last, parameter? that way opSlice would handle all situations.. Dec 19 2003
why? [ .. x] shall be equal to [0 .. x], and [x .. ] shall be equal to [x .. a.length], not? if it shall be equal, then make it equal => just send 0 or a.length as first or second parameter to the ordinary slice function. whats the problem? In article <brvcui$1rr5$1 digitaldaemon.com>, Andy Friesen says...davepermen wrote:what if opSlice just gets 0, or length, as first, or last, parameter? that way opSlice would handle all situations.. Dec 19 2003
Andy Friesen wrote:That only works for sequences. What if opSlice accepted a char[]? The only solution I see is adding opSliceFrom() and opSliceTo(). Dec 19 2003
"Matthew" <matthew.hat stlsoft.dot.org> wrote in message news:brt4c7$1f7h$1 digitaldaemon.com...The problematic part is that a simple implementation would be opSlice(T from); opSlice(T to); How would we distinguish between the two? Dec 19 2003
|