D - Implicit slice bounding
- Matthew (20/20) Dec 18 2003 Any chance we might get the implicit slice bounding?
- Mark J. Brudnak (6/26) Dec 18 2003 There was a lengthy discussion regarding this a couple of weeks ago:
- davepermen (3/23) Dec 19 2003 what if opSlice just gets 0, or length, as first, or last, parameter? th...
- Andy Friesen (4/6) Dec 19 2003 That only works for sequences. What if opSlice accepted a char[]?
- davepermen (6/12) Dec 19 2003 why?
- Ilya Minkov (5/8) Dec 19 2003 STL-like solution: properties for start and end of the array, which may
- Walter (3/7) Dec 19 2003 Yup. That's why it's not in the language :-(
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: http://www.digitalmars.com/drn-bin/wwwnews?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 nastykludges,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 1000to1), 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
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? Matthewwhat if opSlice just gets 0, or length, as first, or last, parameter? that way opSlice would handle all situations..
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..That only works for sequences. What if opSlice accepted a char[]? The only solution I see is adding opSliceFrom() and opSliceTo(). -- andy
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..That only works for sequences. What if opSlice accepted a char[]? The only solution I see is adding opSliceFrom() and opSliceTo(). -- andy
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().STL-like solution: properties for start and end of the array, which may return an iterator and not an index? The [] operator may also return an iterator? -eye
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?Yup. That's why it's not in the language :-(
Dec 19 2003