www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17265] New: WithStatement: Find better Example for what

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 puremagic.com
          Reporter: kdevel 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.

--
Mar 17 2017