[Issue 5749] New: argument evaluation order of chained function from right

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 18 12:30:42 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5749

           Summary: argument evaluation order of chained function from
                    right
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: fawzi at gmx.ch


--- Comment #0 from Fawzi Mohamed <fawzi at gmx.ch> 2011-03-18 12:27:28 PDT ---
I was surprised by the avaluation order of opCall arguments:

    extern(C) int printf(/+const +/char*,...);

    struct A{
      A opCall(int i){
        printf("i=%d\n".ptr,i);
        //return this;
        return *this;
      }
    }

    void main(){
      A a;
      size_t  i;
      a(++i)(++i);
    }


prints

i=2
i=1

because the arguments are evaluated from right.
I found it vers surprising, I would have expected to have them evaluated from
left to right.
This "breaks" whisper style chaining.
I am not sure if/when this behaviour is documented/useful, but I would change
it

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list