digitalmars.D - array assignment overloading change to opIndexAssign()
- Walter (8/8) Jun 09 2004 I'm going to change this to use opIndexAssign() rather than opIndex(); t...
- J Anderson (4/13) Jun 09 2004 Why not have opIndex cause an error message for a few versions of dmd?
- Walter (6/22) Jun 09 2004 the
- Stewart Gordon (10/21) Jun 10 2004 Why swap the arguments over? To confuse people? Or does it somehow
- Sean Kelly (3/15) Jun 10 2004 T opIndexAssign(V value, int index1, int index2, int index3, ...) {}
- Walter (6/22) Jun 10 2004 the
- Matthew (3/26) Jun 10 2004 I think value first is best
- Sean Kelly (6/8) Jun 11 2004 Assuming it's just as easy to parse either way, I prefer this method. I...
- Norbert Nemec (4/30) Jun 13 2004 Might there be any reason to use opIndexAssign with variadic arguments f...
- Kevin Bealer (8/31) Jun 14 2004 Depending on the future of multi-dim arrays, is there a need for:
- Matthew (5/39) Jun 14 2004 Good point.
- Kevin Bealer (3/46) Jun 15 2004 If you mean X3 is highest, then yes.
- Norbert Nemec (11/20) Jun 15 2004 That depends very much on what kind of array you implement. The
- Kevin Bealer (12/32) Jun 15 2004 If you don't like them or can't support them, don't implement them, and ...
- Ivan Senji (19/56) Jun 16 2004 of
- Norbert Nemec (18/26) Jun 16 2004 My multidim-Array proposal is more flexible. You can mix slicing and par...
I'm going to change this to use opIndexAssign() rather than opIndex(); the latter will now only be used as array rvalues. This is necessary to support multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... } In fact, at the moment you can write both functions, use the same function body, and have a smooth integration with the next DMD.
Jun 09 2004
Walter wrote:I'm going to change this to use opIndexAssign() rather than opIndex(); the latter will now only be used as array rvalues. This is necessary to support multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... } In fact, at the moment you can write both functions, use the same function body, and have a smooth integration with the next DMD.Why not have opIndex cause an error message for a few versions of dmd? -- -Anderson: http://badmama.com.au/~anderson/
Jun 09 2004
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:ca81fl$rs6$1 digitaldaemon.com...Walter wrote:theI'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary tofunctionmulti-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... } In fact, at the moment you can write both functions, use the sameI'll do that if possible. In the meantime, this is just a heads-up.body, and have a smooth integration with the next DMD.Why not have opIndex cause an error message for a few versions of dmd?
Jun 09 2004
Walter wrote:I'm going to change this to use opIndexAssign() rather than opIndex(); the latter will now only be used as array rvalues. This is necessary to support multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?In fact, at the moment you can write both functions, use the same function body, and have a smooth integration with the next DMD.Or make one call the other. Is there going to be an opSliceAssign as well? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jun 10 2004
In article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...Walter wrote:T opIndexAssign(V value, int index1, int index2, int index3, ...) {} :) SeanI'm going to change this to use opIndexAssign() rather than opIndex(); the latter will now only be used as array rvalues. This is necessary to support multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 10 2004
"Sean Kelly" <sean f4.ca> wrote in message news:ca9ulq$o30$1 digitaldaemon.com...In article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...theWalter wrote:I'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary toMaybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}T opIndexAssign(V value, int index1, int index2, int index3, ...) {}multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 10 2004
"Walter" <newshound digitalmars.com> wrote in message news:cabiqn$9a9$2 digitaldaemon.com..."Sean Kelly" <sean f4.ca> wrote in message news:ca9ulq$o30$1 digitaldaemon.com...I think value first is bestIn article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...theWalter wrote:I'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary toMaybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}T opIndexAssign(V value, int index1, int index2, int index3, ...) {}multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 10 2004
In article <cabiqn$9a9$2 digitaldaemon.com>, Walter says...Maybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}Assuming it's just as easy to parse either way, I prefer this method. It maintains consistency with opIndex and somehow seems clearer as it reads in the same order that the original statement is written. Would we lose anything by putting the value last? Sean
Jun 11 2004
Walter wrote:"Sean Kelly" <sean f4.ca> wrote in message news:ca9ulq$o30$1 digitaldaemon.com...Might there be any reason to use opIndexAssign with variadic arguments for some exotic data-structure? In that case, value-first might be the better solution.In article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...theWalter wrote:I'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary toMaybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}T opIndexAssign(V value, int index1, int index2, int index3, ...) {}multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 13 2004
In article <cabiqn$9a9$2 digitaldaemon.com>, Walter says..."Sean Kelly" <sean f4.ca> wrote in message news:ca9ulq$o30$1 digitaldaemon.com...Depending on the future of multi-dim arrays, is there a need for: T opIndexAssign(Value V, int i1, int i2, int i3); // X3 T opIndexAssign(Value V, int i1, int i2); // X2 T opIndexAssign(Value V, int i1); // X1 .. on the same array? I.e. the X1 model would return a two-dim slice of the original? If so, maybe Value should be first for symmetry. KevinIn article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...theWalter wrote:I'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary toMaybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}T opIndexAssign(V value, int index1, int index2, int index3, ...) {}multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 14 2004
"Kevin Bealer" <Kevin_member pathlink.com> wrote in message news:calav2$2lmo$1 digitaldaemon.com...In article <cabiqn$9a9$2 digitaldaemon.com>, Walter says...Good point. Presumably the higher order overloads are slices, and the lowest is for accessing the actual cell/element?"Sean Kelly" <sean f4.ca> wrote in message news:ca9ulq$o30$1 digitaldaemon.com...Depending on the future of multi-dim arrays, is there a need for: T opIndexAssign(Value V, int i1, int i2, int i3); // X3 T opIndexAssign(Value V, int i1, int i2); // X2 T opIndexAssign(Value V, int i1); // X1 .. on the same array? I.e. the X1 model would return a two-dim slice of the original? If so, maybe Value should be first for symmetry.In article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...theWalter wrote:I'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary toMaybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}T opIndexAssign(V value, int index1, int index2, int index3, ...) {}multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 14 2004
In article <calc77$2nf4$1 digitaldaemon.com>, Matthew says..."Kevin Bealer" <Kevin_member pathlink.com> wrote in message news:calav2$2lmo$1 digitaldaemon.com...If you mean X3 is highest, then yes. KevinIn article <cabiqn$9a9$2 digitaldaemon.com>, Walter says...Good point. Presumably the higher order overloads are slices, and the lowest is for accessing the actual cell/element?"Sean Kelly" <sean f4.ca> wrote in message news:ca9ulq$o30$1 digitaldaemon.com...Depending on the future of multi-dim arrays, is there a need for: T opIndexAssign(Value V, int i1, int i2, int i3); // X3 T opIndexAssign(Value V, int i1, int i2); // X2 T opIndexAssign(Value V, int i1); // X1 .. on the same array? I.e. the X1 model would return a two-dim slice of the original? If so, maybe Value should be first for symmetry.In article <ca9q2r$gfg$1 digitaldaemon.com>, Stewart Gordon says...theWalter wrote:I'm going to change this to use opIndexAssign() rather than opIndex();supportlatter will now only be used as array rvalues. This is necessary toMaybe it should be: T opIndexAssign(int index1, int index2, int index3, ... , V value) {}T opIndexAssign(V value, int index1, int index2, int index3, ...) {}multi-index arrays. So, replace: T opIndex(int index, V value) { ... } with: T opIndexAssign(V value, int index) { ... }Why swap the arguments over? To confuse people? Or does it somehow simplify the extension to multi-indexes?
Jun 15 2004
Kevin Bealer wrote:Depending on the future of multi-dim arrays, is there a need for: T opIndexAssign(Value V, int i1, int i2, int i3); // X3 T opIndexAssign(Value V, int i1, int i2); // X2 T opIndexAssign(Value V, int i1); // X1 .. on the same array? I.e. the X1 model would return a two-dim slice of the original? If so, maybe Value should be first for symmetry.That depends very much on what kind of array you implement. The language-supported arrays that I'm proposing in my draft allow indexing and slicing only for exactly the same dimensionality as the array. For indexing only certain dimensions, you will have to do something like int[3,3,3] A = ...; int[3,3] B = A[1,,]; So for these arrays, the answer to your question would be "no". Anyhow: the overloaded opIndexAssign is meant to be flexible to be used in all kinds of data-structures. Who knows when somebody finds a use for different numbers of indices in some data-structure?
Jun 15 2004
In article <camr4m$1tfl$1 digitaldaemon.com>, Norbert Nemec says...Kevin Bealer wrote:If you don't like them or can't support them, don't implement them, and the corresponding slicing operation becomes forbidden. This is analagous to current language definitions, where you opt to support comparisons by defining opCmp, etc. In my proposed syntax, I was assuming that a 5x10x20 array would not produce a 3x3 array no matter how you slice it. You either slice out a 10x20 or a 5x10, or a 5 or a 20, depending on how many layers you peel off and whether it is a column-first or row-first implementation. Column versus row ordering would be determined by the implementor or the language and would determine whether you get the first N indices or the last N when you slice and dice. KevinDepending on the future of multi-dim arrays, is there a need for: T opIndexAssign(Value V, int i1, int i2, int i3); // X3 T opIndexAssign(Value V, int i1, int i2); // X2 T opIndexAssign(Value V, int i1); // X1 .. on the same array? I.e. the X1 model would return a two-dim slice of the original? If so, maybe Value should be first for symmetry.That depends very much on what kind of array you implement. The language-supported arrays that I'm proposing in my draft allow indexing and slicing only for exactly the same dimensionality as the array. For indexing only certain dimensions, you will have to do something like int[3,3,3] A = ...; int[3,3] B = A[1,,]; So for these arrays, the answer to your question would be "no". Anyhow: the overloaded opIndexAssign is meant to be flexible to be used in all kinds of data-structures. Who knows when somebody finds a use for different numbers of indices in some data-structure?
Jun 15 2004
"Kevin Bealer" <Kevin_member pathlink.com> wrote in message news:cans7t$fl1$1 digitaldaemon.com...In article <camr4m$1tfl$1 digitaldaemon.com>, Norbert Nemec says...ofKevin Bealer wrote:Depending on the future of multi-dim arrays, is there a need for: T opIndexAssign(Value V, int i1, int i2, int i3); // X3 T opIndexAssign(Value V, int i1, int i2); // X2 T opIndexAssign(Value V, int i1); // X1 .. on the same array? I.e. the X1 model would return a two-dim sliceandthe original? If so, maybe Value should be first for symmetry.That depends very much on what kind of array you implement. The language-supported arrays that I'm proposing in my draft allow indexingindexingslicing only for exactly the same dimensionality as the array. Fortheonly certain dimensions, you will have to do something like int[3,3,3] A = ...; int[3,3] B = A[1,,]; So for these arrays, the answer to your question would be "no". Anyhow:ofoverloaded opIndexAssign is meant to be flexible to be used in all kindsnumbersdata-structures. Who knows when somebody finds a use for differenttheof indices in some data-structure?If you don't like them or can't support them, don't implement them, andcorresponding slicing operation becomes forbidden. This is analagous tocurrentlanguage definitions, where you opt to support comparisons by definingopCmp, Not true! opCmp is not an option, when you write a class you get it (want it or not). Couldn't resist to mention opCmp(and opEquals) topic again :)etc. In my proposed syntax, I was assuming that a 5x10x20 array would notproduce a3x3 array no matter how you slice it. You either slice out a 10x20 or a5x10,or a 5 or a 20, depending on how many layers you peel off and whether itis acolumn-first or row-first implementation. Column versus row orderingwould bedetermined by the implementor or the language and would determine whetheryouget the first N indices or the last N when you slice and dice. Kevin
Jun 16 2004
Kevin Bealer wrote:In my proposed syntax, I was assuming that a 5x10x20 array would not produce a 3x3 array no matter how you slice it. You either slice out a 10x20 or a 5x10, or a 5 or a 20, depending on how many layers you peel off and whether it is a column-first or row-first implementation. Column versus row ordering would be determined by the implementor or the language and would determine whether you get the first N indices or the last N when you slice and dice.My multidim-Array proposal is more flexible. You can mix slicing and partial indexing in one expression: int[[4]] A = new int[5,10,20,2]; int[[3]] B = A[2,1..7:2,5..6,]; Here, the first dimension is indexed, to the resulting array has one dimension less. The second and the third dimension are both sliced. The second one with stride 2, so it leaves three entries (1,3 and 5) the second one leaves range 1. The last dimension is left untouched. The result would be an 3x1x2 array. Row versus column ordering is handled fully transparently to the programmer. The default is Fortran-style alignment, but you can just as well create a C-style array in memory. The user of an array does not need to think about the memory layout. For more details, see http://homepages.uni-regensburg.de/~nen10015/documents/D-multidimarray.html Ciao, Nobbi
Jun 16 2004