digitalmars.D - opSliceAssign
- Manfred Nowak (3/3) Aug 18 2005 Because assigning to array slices is possible, why dont D has an
- Chris Sauls (15/19) Aug 18 2005 Its a good question, and probably has something to do with determining t...
- Stewart Gordon (14/23) Aug 23 2005 Why the ...? And why return a size_t? And why not have the order match...
- Chris Sauls (8/29) Aug 23 2005 I thought it was clever at the time... Now that I think about it, I gues...
- Jarrett Billingsley (3/5) Aug 18 2005 I've asked this same question many times myself.
- Shammah Chancellor (13/18) Aug 19 2005 I think the rationale for this is:
Because assigning to array slices is possible, why dont D has an opSliceAssign? -manfred
Aug 18 2005
Manfred Nowak wrote:Because assigning to array slices is possible, why dont D has an opSliceAssign? -manfredIts a good question, and probably has something to do with determining the signature of the function. Now that D has its "typesafe variadic arguments" I figure an opSliceAssign might look like: -- Chris Sauls
Aug 18 2005
Chris Sauls wrote: <snip>Its a good question, and probably has something to do with determining the signature of the function. Now that D has its "typesafe variadic arguments" I figure an opSliceAssign might look like: values...) {Why the ...? And why return a size_t? And why not have the order match opIndexAssign? int[] opSliceAssign(int[] values, size_t begin, size_t end) { ... } Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Aug 23 2005
Stewart Gordon wrote:Chris Sauls wrote: <snip>I thought it was clever at the time... Now that I think about it, I guess it is kind of pointless. A formal array would work fine.Its a good question, and probably has something to do with determining the signature of the function. Now that D has its "typesafe variadic arguments" I figure an opSliceAssign might look like: values...) {Why the ...?And why return a size_t?I think I was envisioning it returning a length or something... honestly I forget what I was on to.And why not have the order match opIndexAssign?That was just because of the variadic at the end. Once that's gone, there's no reason, so yes it should match, just as you presented below.int[] opSliceAssign(int[] values, size_t begin, size_t end) { ... }-- Chris Sauls
Aug 23 2005
"Manfred Nowak" <svv1999 hotmail.com> wrote in message news:de1lv7$1uln$1 digitaldaemon.com...Because assigning to array slices is possible, why dont D has an opSliceAssign?I've asked this same question many times myself.
Aug 18 2005
In article <de25l3$2n0u$1 digitaldaemon.com>, Jarrett Billingsley says..."Manfred Nowak" <svv1999 hotmail.com> wrote in message news:de1lv7$1uln$1 digitaldaemon.com...I think the rationale for this is: A slice is supposed to return another instance of the object with a subrange. Because of the order of operation, you can then assign to it, and opAssign would then take over IE: foo[1..2] = 10 would be rewritten as: foo.opSlice(1,2).opAssign(10) However, this is not really a good thing. Since if that's how normal slices worked, using opslice to imply a copy on normal arrays wouldn't work. Normally when a slice operator is used with an array as an lvalue, it causes an array copy. This is functionally objects cannot obtain currently. I vote for an opSliceAssign as well! :)Because assigning to array slices is possible, why dont D has an opSliceAssign?I've asked this same question many times myself.
Aug 19 2005