[Issue 17265] New: WithStatement: Find better Example for what "with" really does

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Mar 17 13:10:14 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17265

          Issue ID: 17265
           Summary: WithStatement: Find better Example for what "with"
                    really does
           Product: D
           Version: D2
          Hardware: Other
                OS: Other
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dlang.org
          Assignee: nobody at puremagic.com
          Reporter: kdevel at vogtner.de

The documentation 

   http://dlang.org/spec/statement.html#WithStatement

claims an equivalence of 

   with (expression)
   {
       ...
       ident;
   }

and

   {
       Object tmp;
       tmp = expression;
       ...
       tmp.ident;
   }

This does not hold if "Object" refers to a struct type. While the former
invokes ident on the original object (struct), the latter invokes it on a copy.
Hence there is no equivalence.

--


More information about the Digitalmars-d-bugs mailing list