From Jason Turner

[diff.basic]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpyxxdwm6m/{from.md → to.md} +21 -5
tmp/tmpyxxdwm6m/{from.md → to.md} RENAMED
@@ -1,44 +1,60 @@
1
  ### [[basic]]: basics <a id="diff.basic">[[diff.basic]]</a>
2
 
3
  **Change:** C++ does not have “tentative definitions” as in C.
4
- E.g., at file scope,
 
 
 
5
 
6
  ``` cpp
7
  int i;
8
  int i;
9
  ```
10
 
11
- is valid in C, invalid in C++. This makes it impossible to define
12
- mutually referential file-local objects with static storage duration, if
13
- initializers are restricted to the syntactic forms of C. For example,
 
 
 
 
 
 
14
 
15
  ``` cpp
16
  struct X { int i; struct X* next; };
17
 
18
  static struct X a;
19
  static struct X b = { 0, &a };
20
  static struct X a = { 1, &b };
21
  ```
22
 
 
 
23
  **Rationale:** This avoids having different initialization rules for
24
  fundamental types and user-defined types. **Effect on original
25
  feature:** Deletion of semantically well-defined feature. Semantic
26
  transformation. In C++, the initializer for one of a set of
27
  mutually-referential file-local objects with static storage duration
28
  must invoke a function call to achieve the initialization. Seldom.
29
 
30
- **Change:** A `struct` is a scope in C++, not in C. For example,
 
 
31
 
32
  ``` cpp
33
  struct X {
34
  struct Y { int a; } b;
35
  };
36
  struct Y c;
37
  ```
38
 
39
  is valid in C but not in C++, which would require `X::Y c;`.
 
 
 
40
  **Rationale:** Class scope is crucial to C++, and a struct is a class.
41
  **Effect on original feature:** Change to semantics of well-defined
42
  feature. Semantic transformation. C programs use `struct` extremely
43
  frequently, but the change is only noticeable when `struct`,
44
  enumeration, or enumerator names are referred to outside the `struct`.
 
1
  ### [[basic]]: basics <a id="diff.basic">[[diff.basic]]</a>
2
 
3
  **Change:** C++ does not have “tentative definitions” as in C.
4
+
5
+ [*Example 1*:
6
+
7
+ At file scope,
8
 
9
  ``` cpp
10
  int i;
11
  int i;
12
  ```
13
 
14
+ is valid in C, invalid in C++.
15
+
16
+ *end example*]
17
+
18
+ This makes it impossible to define mutually referential file-local
19
+ objects with static storage duration, if initializers are restricted to
20
+ the syntactic forms of C.
21
+
22
+ [*Example 2*:
23
 
24
  ``` cpp
25
  struct X { int i; struct X* next; };
26
 
27
  static struct X a;
28
  static struct X b = { 0, &a };
29
  static struct X a = { 1, &b };
30
  ```
31
 
32
+ — *end example*]
33
+
34
  **Rationale:** This avoids having different initialization rules for
35
  fundamental types and user-defined types. **Effect on original
36
  feature:** Deletion of semantically well-defined feature. Semantic
37
  transformation. In C++, the initializer for one of a set of
38
  mutually-referential file-local objects with static storage duration
39
  must invoke a function call to achieve the initialization. Seldom.
40
 
41
+ **Change:** A `struct` is a scope in C++, not in C.
42
+
43
+ [*Example 3*:
44
 
45
  ``` cpp
46
  struct X {
47
  struct Y { int a; } b;
48
  };
49
  struct Y c;
50
  ```
51
 
52
  is valid in C but not in C++, which would require `X::Y c;`.
53
+
54
+ — *end example*]
55
+
56
  **Rationale:** Class scope is crucial to C++, and a struct is a class.
57
  **Effect on original feature:** Change to semantics of well-defined
58
  feature. Semantic transformation. C programs use `struct` extremely
59
  frequently, but the change is only noticeable when `struct`,
60
  enumeration, or enumerator names are referred to outside the `struct`.