Bug 2032 – Documentation for creating a class on the stack is unintuitive

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-04-24T21:34:00Z
Last change time
2015-06-09T05:15:16Z
Keywords
spec
Assigned to
bugzilla
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2008-04-24T21:34:52Z
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
Comment #1 by bugzilla — 2008-05-22T04:59:40Z
Fixed dmd 1.030 and 2.014