Re: A possible solution for the opIndexXxxAssign morass

2009-10-15 Thread Fawzi Mohamed
On 2009-10-15 22:55:02 +0200, Fawzi Mohamed said: On 2009-10-15 17:51:56 +0200, "Robert Jacques" said: On Thu, 15 Oct 2009 04:48:57 -0400, Fawzi Mohamed wrote: [...] Note that a ref return for opIndex, could work in most situations. As Bill correctly pointed out sparse matrix offer the mo

Re: A possible solution for the opIndexXxxAssign morass

2009-10-15 Thread Fawzi Mohamed
On 2009-10-15 17:51:56 +0200, "Robert Jacques" said: On Thu, 15 Oct 2009 04:48:57 -0400, Fawzi Mohamed wrote: [...] Note that a ref return for opIndex, could work in most situations. As Bill correctly pointed out sparse matrix offer the most challenging example, there one wants to have two

Re: A possible solution for the opIndexXxxAssign morass

2009-10-15 Thread Robert Jacques
On Thu, 15 Oct 2009 04:48:57 -0400, Fawzi Mohamed wrote: On 2009-10-14 23:09:26 +0200, "Robert Jacques" said: On Wed, 14 Oct 2009 16:49:28 -0400, Andrei Alexandrescu wrote: Jason House wrote: Bill Baxter Wrote: On Wed, Oct 14, 2009 at 7:42 AM, Jason House wrote: Andrei Alexandresc

Re: A possible solution for the opIndexXxxAssign morass

2009-10-15 Thread Steven Schveighoffer
On Thu, 15 Oct 2009 02:58:51 -0400, Don wrote: Andrei Alexandrescu wrote: Also, the much-discussed identity: x @= y<-->x = x @ y is difficult to enforce statically in practice. I think some types would want to define both to achieve good efficiency. It would be hard for the compi

Re: A possible solution for the opIndexXxxAssign morass

2009-10-15 Thread Fawzi Mohamed
On 2009-10-14 23:09:26 +0200, "Robert Jacques" said: On Wed, 14 Oct 2009 16:49:28 -0400, Andrei Alexandrescu wrote: Jason House wrote: Bill Baxter Wrote: On Wed, Oct 14, 2009 at 7:42 AM, Jason House wrote: Andrei Alexandrescu Wrote: Right now we're in trouble with operators: opIndex

Re: A possible solution for the opIndexXxxAssign morass

2009-10-15 Thread Don
Andrei Alexandrescu wrote: Don wrote: Well timed. I just wrote this operator overloading proposal, part 1. http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7 I concentrated on getting the use cases established. I'm not sure multiplication is generally commutative (e.g. in linear a

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Robert Jacques
On Wed, 14 Oct 2009 16:49:28 -0400, Andrei Alexandrescu wrote: Jason House wrote: Bill Baxter Wrote: On Wed, Oct 14, 2009 at 7:42 AM, Jason House wrote: Andrei Alexandrescu Wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Jason House
Bill Baxter Wrote: > On Wed, Oct 14, 2009 at 7:42 AM, Jason House > wrote: > > Andrei Alexandrescu Wrote: > > > >> Right now we're in trouble with operators: opIndex and opIndexAssign > >> don't seem to be up to snuff because they don't catch operations like > >> > >> a[b] += c; > >> > >> with re

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Andrei Alexandrescu
Jason House wrote: Bill Baxter Wrote: On Wed, Oct 14, 2009 at 7:42 AM, Jason House wrote: Andrei Alexandrescu Wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expres

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Bill Baxter
On Wed, Oct 14, 2009 at 9:34 AM, Bill Baxter wrote: > On Wed, Oct 14, 2009 at 7:42 AM, Jason House > wrote: >> Andrei Alexandrescu Wrote: >> >>> Right now we're in trouble with operators: opIndex and opIndexAssign >>> don't seem to be up to snuff because they don't catch operations like >>> >>> a

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Bill Baxter
On Wed, Oct 14, 2009 at 7:42 AM, Jason House wrote: > Andrei Alexandrescu Wrote: > >> Right now we're in trouble with operators: opIndex and opIndexAssign >> don't seem to be up to snuff because they don't catch operations like >> >> a[b] += c; >> >> with reasonable expressiveness and efficiency.

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Jason House
Andrei Alexandrescu Wrote: > Right now we're in trouble with operators: opIndex and opIndexAssign > don't seem to be up to snuff because they don't catch operations like > > a[b] += c; > > with reasonable expressiveness and efficiency. I would hope that *= += /= and friends could all be handle

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Denis Koroskin
On Wed, 14 Oct 2009 18:39:27 +0400, Robert Jacques wrote: On Wed, 14 Oct 2009 10:31:06 -0400, Andrei Alexandrescu wrote: Don wrote: Well timed. I just wrote this operator overloading proposal, part 1. http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7 I concentrated on getti

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Robert Jacques
On Wed, 14 Oct 2009 10:31:06 -0400, Andrei Alexandrescu wrote: Don wrote: Well timed. I just wrote this operator overloading proposal, part 1. http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7 I concentrated on getting the use cases established. I'm not sure multiplication is

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Robert Jacques
On Wed, 14 Oct 2009 06:11:22 -0400, Kagamin wrote: Robert Jacques Wrote: Also needed is an extension of the opDollar to return different values based on the index: opDollar(size_t index); Dollar is just a synonym for length, isn't it? User types can also override Dollar, though I don't re

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Andrei Alexandrescu
Don wrote: Well timed. I just wrote this operator overloading proposal, part 1. http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7 I concentrated on getting the use cases established. I'm not sure multiplication is generally commutative (e.g. in linear algebra it isn't). So why sho

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Andrei Alexandrescu
Lars T. Kyllingstad wrote: Kagamin wrote: Robert Jacques Wrote: Also needed is an extension of the opDollar to return different values based on the index: opDollar(size_t index); Dollar is just a synonym for length, isn't it? Yes, but if opIndex and opSlice take multiple indices (like i

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Bill Baxter
On Wed, Oct 14, 2009 at 12:48 AM, Lars T. Kyllingstad wrote: > Don wrote: >> >> Andrei Alexandrescu wrote: >>> >>> Right now we're in trouble with operators: opIndex and opIndexAssign >>> don't seem to be up to snuff because they don't catch operations like >>> >>> a[b] += c; >>> >>> with reasonab

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Kagamin
Lars T. Kyllingstad Wrote: > Yes, but if opIndex and opSlice take multiple indices (like in a matrix) > opDollar needs a way to distinguish between the different dimensions. size_t length(size_t idx);

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Lars T. Kyllingstad
Kagamin wrote: Robert Jacques Wrote: Also needed is an extension of the opDollar to return different values based on the index: opDollar(size_t index); Dollar is just a synonym for length, isn't it? Yes, but if opIndex and opSlice take multiple indices (like in a matrix) opDollar needs

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Kagamin
Robert Jacques Wrote: > Also needed is an extension of the opDollar to return different values > based on the index: > opDollar(size_t index); Dollar is just a synonym for length, isn't it?

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Lars T. Kyllingstad
Don wrote: Lars T. Kyllingstad wrote: Don wrote: Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this i

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Don
Lars T. Kyllingstad wrote: Don wrote: Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurred

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread bearophile
Don: > BTW we need to deal with slices as well as indexes. I think the way to > do this is to make a slice into a type of index. Such slice also needs a way to specify the end of the enclosing interval, the $ syntax. Slice may enjoy a lot a third optional argument (default = 1), that represents

Re: A possible solution for the opIndexXxxAssign morass

2009-10-14 Thread Lars T. Kyllingstad
Don wrote: Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurred to me: we could simply use

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Bill Baxter
On Tue, Oct 13, 2009 at 10:39 AM, Chad J wrote: > Forgotten already? Apparently, yes! > http://prowiki.org/wiki4d/wiki.cgi?DocComments/Property#Semantic > > This is the same problem as property lvalue-ness and it has the same > solution.  When property rewriting is done correctly, the opIndexAss

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Bill Baxter
On Tue, Oct 13, 2009 at 8:56 AM, Don wrote: > Well timed. I just wrote this operator overloading proposal, part 1. > http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7 > I concentrated on getting the use cases established. > > The indexing thing was something I didn't have a solution f

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Chad J
Forgotten already? http://prowiki.org/wiki4d/wiki.cgi?DocComments/Property#Semantic This is the same problem as property lvalue-ness and it has the same solution. When property rewriting is done correctly, the opIndexAssign problem can then be solved almost for free. Just treat opIndex expressi

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Robert Jacques
On Tue, 13 Oct 2009 13:08:59 -0400, Andrei Alexandrescu wrote: Bill Baxter wrote: Huh? It didn't sound to me like it would get rid of anything, except for the use of the word "index" in many methods that have to do with index operations. That just seems confusing to me. I think the opInde

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Robert Jacques
On Tue, 13 Oct 2009 11:56:36 -0400, Don wrote: Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this id

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Bill Baxter
On Tue, Oct 13, 2009 at 10:22 AM, JC wrote: > This idea along with a slice overload would save me a lot of pain and > performance while working with matrices in my production code. Any ideas > when this could be implemented in D1? > Jonathan It won't be implemented in D1. Stability -- it's the

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread JC
This idea along with a slice overload would save me a lot of pain and performance while working with matrices in my production code. Any ideas when this could be implemented in D1? Jonathan Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't se

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Bill Baxter
On Tue, Oct 13, 2009 at 10:08 AM, Andrei Alexandrescu wrote: > Bill Baxter wrote: >> >> Huh? It didn't sound to me like it would get rid of anything, except >> for the use of the word "index" in many methods that have to do with >> index operations.  That just seems confusing to me.   I think the

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Bill Baxter
On Tue, Oct 13, 2009 at 10:00 AM, Steven Schveighoffer wrote: > On Tue, 13 Oct 2009 12:44:21 -0400, Denis Koroskin <2kor...@gmail.com> > wrote: > >> Another thing I dislike about this proposal is that "a[b] += c;" >> translates into "opAddAssign" and doesn't mention "index" while "a[b] = c;" >> do

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Andrei Alexandrescu
Bill Baxter wrote: Huh? It didn't sound to me like it would get rid of anything, except for the use of the word "index" in many methods that have to do with index operations. That just seems confusing to me. I think the opIndexXxxAssign functions may need to be added, but adding them by overlo

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Steven Schveighoffer
On Tue, 13 Oct 2009 12:44:21 -0400, Denis Koroskin <2kor...@gmail.com> wrote: Another thing I dislike about this proposal is that "a[b] += c;" translates into "opAddAssign" and doesn't mention "index" while "a[b] = c;" does ("opIndexAssign"). I think the optimization translates to opAssig

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Michel Fortin
On 2009-10-13 11:16:01 -0400, Andrei Alexandrescu said: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurred to me:

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Denis Koroskin
On Tue, 13 Oct 2009 20:34:06 +0400, Robert Jacques wrote: On Tue, 13 Oct 2009 12:28:05 -0400, Denis Koroskin <2kor...@gmail.com> wrote: On Tue, 13 Oct 2009 19:16:01 +0400, Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to b

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Robert Jacques
On Tue, 13 Oct 2009 12:21:20 -0400, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: On Tue, 13 Oct 2009 11:16:01 -0400, Andrei Alexandrescu wrote: There's no chance of ambiguity because the parameter counts are different. Moreover, this scales to multiple indexes: a[b1, b2, ...,

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Bill Baxter
On Tue, Oct 13, 2009 at 9:08 AM, Steven Schveighoffer wrote: > On Tue, 13 Oct 2009 11:16:01 -0400, Andrei Alexandrescu > wrote: > >> Right now we're in trouble with operators: opIndex and opIndexAssign don't >> seem to be up to snuff because they don't catch operations like >> >> a[b] += c; >> >>

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Robert Jacques
On Tue, 13 Oct 2009 12:28:05 -0400, Denis Koroskin <2kor...@gmail.com> wrote: On Tue, 13 Oct 2009 19:16:01 +0400, Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] +

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Denis Koroskin
On Tue, 13 Oct 2009 19:16:01 +0400, Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurre

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Andrei Alexandrescu
Steven Schveighoffer wrote: On Tue, 13 Oct 2009 11:16:01 -0400, Andrei Alexandrescu wrote: There's no chance of ambiguity because the parameter counts are different. Moreover, this scales to multiple indexes: a[b1, b2, ..., bn] = c gets rewritten as a.opAddAssign(b1, b2, ..., bn, c) I'm g

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Steven Schveighoffer
On Tue, 13 Oct 2009 11:16:01 -0400, Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurre

Re: A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Don
Andrei Alexandrescu wrote: Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurred to me: we could simply use overloading

A possible solution for the opIndexXxxAssign morass

2009-10-13 Thread Andrei Alexandrescu
Right now we're in trouble with operators: opIndex and opIndexAssign don't seem to be up to snuff because they don't catch operations like a[b] += c; with reasonable expressiveness and efficiency. Last night this idea occurred to me: we could simply use overloading with the existing operator