[Issue 2032] New: Documentation for creating a class on the stack is unintuitive
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 24 19:34:53 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2032
Summary: Documentation for creating a class on the stack is
unintuitive
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 at digitalmars.com
ReportedBy: schveiguy at 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
--
More information about the Digitalmars-d-bugs
mailing list