www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4553] New: D2 Language Docs: http://www.digitalmars.com/d/2.0/struct.html

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4553

           Summary: D2 Language Docs:
                    http://www.digitalmars.com/d/2.0/struct.html
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



10:43:56 PDT ---
"Static Initialization of Structs"

There is inconsistency between the examples.
Replace X with S in all the examples.

In the 4th example, this line:
S s = { 1, i };   // q.a = 1, q.b = i, q.c = 0, q.d = 7

Should be replaced with:        
S q = { 1, i };   // q.a = 1, q.b = i, q.c = 0, q.d = 7



"Const and Invariant Structs"

In the code example the statement t = s; is not compilable:

const struct S { int a; int b = 2; }

void main()
{
    S s = S(3);    // initializes s.a to 3
    S t;           // initializes t.a to 0
    t = s;         // ok, t.a is now 3
    //~ t.a = 4;   // error, t.a is const
}

test3.d(29): Error: variable test3.main.t cannot modify const



"Struct Constructors"

There are no code examples here. A simple one could be added:

struct S {
    int x;
    int y;

    this (int x_val, int y_val) {
        x = x_val;
        y = y_val;
    }
}

void main() {
    S s = S(4, 5);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 01 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4553


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



14:14:56 PST ---
https://github.com/D-Programming-Language/d-programming-language.org/pull/54

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 15 2012