Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 19, 2004 opCall bug | ||||
---|---|---|---|---|
| ||||
The following program doesn't compile:
class caller {
caller opCall (out int i) {
i = 10;
return this;
}
}
void main (char[][] args) {
caller c = new caller;
int x,y;
c(x)(y);
}
It gives this error:
opcall.d(11): declaration main.x is already defined
Compiler bug? Or did I do something stupid?
--
- Mik Mifflin
|
February 19, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | In article <c133a2$1cun$1@digitaldaemon.com>, Mik Mifflin says... >void main (char[][] args) { > caller c = new caller; > int x,y; > c(x)(y); <<----: >} | | HERE I don't think you can chain a function or opCall in that manner... The following works fine... void main (char[][] args) { caller c = new caller; int x,y; c(x); c(y); } |
February 19, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew | you should be able to do that. done similar things yet.. i'll have a closer look... uhm.. tomorrow.. "Andrew" <Andrew_member@pathlink.com> schrieb im Newsbeitrag news:c13739$1jlt$1@digitaldaemon.com... > In article <c133a2$1cun$1@digitaldaemon.com>, Mik Mifflin says... > > >void main (char[][] args) { > > caller c = new caller; > > int x,y; > > c(x)(y); <<----: > >} | > | > HERE > > I don't think you can chain a function or opCall in that manner... The following works fine... > > void main (char[][] args) { > caller c = new caller; > int x,y; > c(x); > c(y); > } > > |
February 19, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew | Andrew wrote: > In article <c133a2$1cun$1@digitaldaemon.com>, Mik Mifflin says... > >>void main (char[][] args) { >> caller c = new caller; >> int x,y; >> c(x)(y); <<----: >>} | > | > HERE > > I don't think you can chain a function or opCall in that manner... The following works fine... > > void main (char[][] args) { > caller c = new caller; > int x,y; > c(x); > c(y); > } I can in this instance, as I return a caller object. -- - Mik Mifflin |
February 19, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew | Andrew wrote:
[...]
> The following works fine...
[...]
However, a very misleading error message.
So long.
|
February 19, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | Mik Mifflin wrote: > The following program doesn't compile: > class caller { > caller opCall (out int i) { > i = 10; > return this; > } > } > > void main (char[][] args) { > caller c = new caller; > int x,y; > c(x)(y); > } > > It gives this error: > opcall.d(11): declaration main.x is already defined > > Compiler bug? Or did I do something stupid? > A temporary workaround is '(c(x)(y))', with the extra parentheses. The error goes away and it works as expected.. -- - Mik Mifflin |
February 20, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | Mik Mifflin wrote:
> A temporary workaround is '(c(x)(y))', with the extra parentheses. The
> error goes away and it works as expected..
This is a cool thing. I am searching for something like that in the thread `[experts] opComma'.
`cast(void) c(x)(y)' also works.
So long.
|
February 20, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | In article <c138s9$1n7c$1@digitaldaemon.com>, davepermen says... > >you should be able to do that. done similar things yet.. > >i'll have a closer look... uhm.. tomorrow.. > IC. Could you please explain some of the advantages and disadvantages of doing things this way? Other than being able to simultaneously assign a value to multiple variables, what are some other uses for this feature? Thanks, Andrew |
February 20, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew | Andrew wrote: > In article <c138s9$1n7c$1@digitaldaemon.com>, davepermen says... >> >>you should be able to do that. done similar things yet.. >> >>i'll have a closer look... uhm.. tomorrow.. >> > > IC. Could you please explain some of the advantages and disadvantages of doing things this way? > > Other than being able to simultaneously assign a value to multiple variables, what are some other uses for this feature? > > Thanks, > Andrew I don't think the point is if anyone actually has a use for it, the point is that it should work, and does not. -- - Mik Mifflin |
February 20, 2004 Re: opCall bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mik Mifflin | In article <c15bp3$2k3l$1@digitaldaemon.com>, Mik Mifflin says... > >Andrew wrote: > >> In article <c138s9$1n7c$1@digitaldaemon.com>, davepermen says... >>> >>>you should be able to do that. done similar things yet.. >>> >>>i'll have a closer look... uhm.. tomorrow.. >>> >> >> IC. Could you please explain some of the advantages and disadvantages of doing things this way? >> >> Other than being able to simultaneously assign a value to multiple variables, what are some other uses for this feature? >> >> Thanks, >> Andrew > >I don't think the point is if anyone actually has a use for it, the point is that it should work, and does not. > >-- > - Mik Mifflin I completely understand that Mik. I simply wanted to expand my knowledge. Thanks anyhow. Andrew |
Copyright © 1999-2021 by the D Language Foundation