Skip to content

Commit

Permalink
Apply Andrej's English review
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jun 3, 2013
1 parent 2ad0347 commit 53ce999
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion attribute.dd
Expand Up @@ -422,7 +422,7 @@ $(H3 $(LNAME2 disable, $(D @disable) Attribute))
---

$(P $(XLINK2 struct.html#Struct-Constructor, Disabling struct no-arg constructor)
makes the struct not default constructible.
disallows default construction of the struct.
)

$(P $(XLINK2 struct.html#StructPostblit, Disabling struct postblit)
Expand Down
29 changes: 15 additions & 14 deletions class.dd
Expand Up @@ -418,9 +418,9 @@ $(GNAME Constructor):
)
)

$(P Constructors can have member function attributes $(D const),
$(D immutable), and $(D shared). The constructible object qualifiers
would be restricted by them.
$(P Constructors can have one of these member function attributes:
$(D const), $(D immutable), and $(D shared). Construction of qualified
objects will then be restricted to the implemented qualified constructors.
)
------
class C {
Expand All @@ -430,13 +430,13 @@ $(GNAME Constructor):
// create mutable object
C m = new C();

// create const object by mutable constructor
// create const object using by mutable constructor
const C c2 = new const C();

// mutable constructor cannot create immutable object
// a mutable constructor cannot create an immutable object
// immutable C i = new immutable C();

// mutable constructor cannot create shared object
// a mutable constructor cannot create a shared object
// shared C s = new shared C();
------

Expand All @@ -454,22 +454,23 @@ $(GNAME Constructor):
immutable i = new immutable C();
------

$(P If the constructor can create unique object, the object would be
implicitly convertible to any qualifiers.
$(P If the constructor can create unique object (e.g. if it is pure),
the object can be implicitly convertible to any qualifiers.
)
------
class C {
this() pure;
// Based on the definition, this creates mutable object. But the
// created object never have any mutable global data.
// Based on the definition, this creates a mutable object. But the
// created object cannot contain any mutable global data.
// Then compiler can guarantee that the created object is unique.

this(int[] arr) immutable pure;
// Based on the definition, this creates immutable object. But the
// argument int[] never appear in the created object so it isn't
// implicitly convertible to immutable. And also it never have any
// Based on the definition, this creates an immutable object. But the
// argument int[] never appears in the created object so it isn't
// implicitly convertible to immutable. Also, it cannot store any
// immutable global data.
// Then compiler can guarantee that the created object is unique.
// Therefore the compiler can guarantee that the created object is
// unique.
}

immutable i = new immutable C(); // this() pure is called
Expand Down
10 changes: 8 additions & 2 deletions struct.dd
Expand Up @@ -342,8 +342,8 @@ $(SECTION3 $(LNAME2 Struct-Constructor, Struct Constructors),
}
------

$(P Struct constructors can have method qualifiers. Qualifier means that
"the constructor would create an object which has that qualifier."
$(P A constructor qualifier allows the object to be constructed with
that specific qualifier.
)

------
Expand All @@ -359,19 +359,25 @@ $(SECTION3 $(LNAME2 Struct-Constructor, Struct Constructors),
{
// Mutable constructor creates mutable object.
S1 m1 = S1(1);

// Constructed mutable object is implicitly convertible to const.
const S1 c1 = S1(1);

// Constructed mutable object is not implicitly convertible to immutable.
// immutable i1 = S1(1);

// Mutable constructor cannot construct immutable object.
// auto x1 = immutable S1(1);

// Immutable constructor cannot construct mutable object.
// auto x2 = S2(1);

// Constructed immutable object is not implicitly convertible to mutable.
// S2 m2 = immutable S2(1);

// Constructed immutable object is implicitly convertible to const.
const S2 c2 = immutable S2(1);

// Immutable constructor creates immutable object.
immutable i2 = immutable S2(1);
}
Expand Down

0 comments on commit 53ce999

Please sign in to comment.