www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2032] New: Documentation for creating a class on the stack is unintuitive

reply d-bugmail puremagic.com writes:

           Summary: Documentation for creating a class on the stack is
           Product: D
           Version: unspecified
          Platform: All
               URL: http://www.digitalmars.com/d/1.0/memory.html#stackclass
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: schveiguy yahoo.com

When I first read the spec on creating a class on the stack, I thought the 3rd
rule meant that I could not instantiate a stack class with parameters to the
constructor.  After asking the question to digitalmars.D.learn, I have learned
that it means the new function cannot have parameters.

Since almost everyone does not use new parameters, and usually uses constructor
parameters, it would be good to clarify that the rule specifically means new
parameters and not constructor parameters.  e.g.:

  * use new with no arguments (constructor arguments are allowed)

And it would be even clearer if there were more examples:

class C { ... }

scope c = new C();      // c is allocated on the stack
scope c2 = new C(5);    // allocated on stack
scope c3 = new(5) C();  // allocated by a custom allocator

Apr 24 2008
parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #1 from bugzilla digitalmars.com  2008-05-22 04:59 -------
Fixed dmd 1.030 and 2.014

May 22 2008