bug : consecutive function calls and -inline

noob-is-noob noob at gmail.com
Sat May 24 03:10:04 PDT 2008


janderson wrote:
> noob-is-noob wrote:
>>> sorry if it has been discussed.
>>>> <snip old code>
> 
> It seems slightly odd that your implicitly copying T[].  I wonder if
> there's even a defined behavior for copying of array indirectly by
> struct.  I'd imagine that what the second version is doing is copying
> the structure each time while the first is not.
> 
> So:
> < snip old code >
> How that helps.
> -Joel

Thank you.
But it seems not related to array copying.
I've tried with a more basic data type.

==code==
import std.stdio ;
class A {
  int c = 0 ;
  A opCall(int b) { c = c + b ; writefln(c) ; return this ; }
}
struct B {
  int c = 0 ;
  B opCall(int b) { c = c + b ; writefln(c) ; return *this ; }
}
void main() {
  A a = new A ;
  B b ;
  a(1)(2)(3) ;
  a(0) ;
  b(1)(2)(3) ;
  b(0) ;
}
==output=== (edited)
-inline version:
1 3 6 6   <- class A
1 3 6 6   <- struct B
non-inline version:
1 3 6 6   <- class A
1 3 6 1   <- struct B

sorry for my bad English.




More information about the Digitalmars-d-learn mailing list