Jump to page: 1 2
Thread overview
array assignment overloading change to opIndexAssign()
Jun 09, 2004
Walter
Jun 09, 2004
J Anderson
Jun 09, 2004
Walter
Jun 10, 2004
Stewart Gordon
Jun 10, 2004
Sean Kelly
Jun 11, 2004
Walter
Jun 11, 2004
Matthew
Jun 11, 2004
Sean Kelly
Jun 13, 2004
Norbert Nemec
Jun 14, 2004
Kevin Bealer
Jun 14, 2004
Matthew
Jun 15, 2004
Kevin Bealer
Jun 15, 2004
Norbert Nemec
Jun 15, 2004
Kevin Bealer
Jun 16, 2004
Ivan Senji
Jun 16, 2004
Norbert Nemec
June 09, 2004
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.


June 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/
June 09, 2004
"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message news:ca81fl$rs6$1@digitaldaemon.com...
> 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?

I'll do that if possible. In the meantime, this is just a heads-up.


June 10, 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.
June 10, 2004
In article <ca9q2r$gfg$1@digitaldaemon.com>, Stewart Gordon says...
>
>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?

T opIndexAssign(V value, int index1, int index2, int index3, ...) {}

:)  Sean


June 11, 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...
> >
> >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?
>
> T opIndexAssign(V value, int index1, int index2, int index3, ...) {}

Maybe it should be:

T opIndexAssign(int index1, int index2, int index3, ... , V value) {}


June 11, 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...
> > In article <ca9q2r$gfg$1@digitaldaemon.com>, Stewart Gordon says...
> > >
> > >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?
> >
> > T opIndexAssign(V value, int index1, int index2, int index3, ...) {}
>
> Maybe it should be:
>
> T opIndexAssign(int index1, int index2, int index3, ... , V value) {}

I think value first is best


June 11, 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


June 13, 2004
Walter wrote:

> 
> "Sean Kelly" <sean@f4.ca> wrote in message news:ca9ulq$o30$1@digitaldaemon.com...
>> In article <ca9q2r$gfg$1@digitaldaemon.com>, Stewart Gordon says...
>> >
>> >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?
>>
>> T opIndexAssign(V value, int index1, int index2, int index3, ...) {}
> 
> Maybe it should be:
> 
> T opIndexAssign(int index1, int index2, int index3, ... , V value) {}

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.

June 14, 2004
In article <cabiqn$9a9$2@digitaldaemon.com>, Walter says...
>
>
>"Sean Kelly" <sean@f4.ca> wrote in message news:ca9ulq$o30$1@digitaldaemon.com...
>> In article <ca9q2r$gfg$1@digitaldaemon.com>, Stewart Gordon says...
>> >
>> >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?
>>
>> T opIndexAssign(V value, int index1, int index2, int index3, ...) {}
>
>Maybe it should be:
>
>T opIndexAssign(int index1, int index2, int index3, ... , V value) {}


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.

Kevin



« First   ‹ Prev
1 2