Skip to content

Commit 910b656

Browse files
committed
Merge remote-tracking branch 'upstream/master' into stable
2 parents 2d17ac3 + 5ddaff3 commit 910b656

19 files changed

+666
-254
lines changed

changelog/release-schedule.dd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Ddoc
33
$(D_S $(TITLE),
44

55
$(UL
6-
$(LI New release are published every $(I two) months, on the first day of every even month.)
7-
$(LI One month before a new release `master` is merged into `stable` and a first beta is released.)
6+
$(LI New releases are published every $(I two) months, on the first day of every even month.)
7+
$(LI One month before a new release, `master` is merged into `stable` and a first beta is released.)
88
$(LI Point releases are published unscheduled when important issues or regressions get fixed.)
99
)
1010

comparison.dd

Lines changed: 70 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ $(COMMUNITY D Concepts Overview,
55
$(P Navigate D's implementation of a few key programming language concepts.)
66

77
$(ITEMIZE
8-
$(A spec/garbage.html, Garbage Collection),
8+
$(A spec/garbage.html, Garbage Collection)
9+
$(ITEMIZE
10+
$(REF_ALTTEXT Manual invocation, GC.enable, core,memory),
11+
$(A spec/function.html#nogc-functions, `@nogc` subset)
12+
),
913
Functions
1014
$(ITEMIZE
11-
$(A spec/type.html#delegates, Function Delegates),
1215
$(A spec/function.html#function-overloading, Function Overloading),
13-
$(A spec/function.html#parameters, `out` parameters for functions),
16+
$(A spec/function.html#ref-params, `ref` and `out` function parameters),
17+
$(A spec/function.html#ref-functions, `ref` functions),
18+
$(A spec/type.html#delegates, Function Delegates),
1419
$(A spec/function.html#nested, Nested functions),
1520
$(A spec/expression.html#FunctionLiteral, Function literals),
1621
$(A spec/function.html#closures, Closures),
1722
$(A spec/function.html#variadic, Typesafe variadic arguments),
1823
$(A lazy-evaluation.html, Lazy function argument evaluation),
19-
$(A spec/function.html#interpretation, Compile time function evaluation),
20-
$(A spec/function.html#pseudo-member, Uniform Function Call Syntax),
21-
$(A spec/attribute.html#UserDefinedAttribute, User-Defined Attributes)
24+
$(A spec/function.html#pseudo-member, Uniform Function Call Syntax)
2225
),
2326
Arrays
2427
$(ITEMIZE
@@ -28,22 +31,21 @@ $(ITEMIZE
2831
$(A spec/arrays.html#slicing, Array slicing),
2932
$(A spec/arrays.html#bounds, Array bounds checking),
3033
$(A spec/expression.html#ArrayLiteral, Array literals),
31-
$(A spec/arrays.html#associative, Associative arrays),
32-
$(A spec/statement.html#SwitchStatement, String switches),
33-
$(A spec/declaration.html#alias, Aliases)
34+
$(A spec/statement.html#string-switch, String switches),
35+
$(A spec/arrays.html#associative, Associative arrays)
3436
),
3537
OOP
3638
$(ITEMIZE
37-
Object Orientation,
39+
$(A spec/class.html, Object Orientation),
3840
$(A spec/interface.html, Interfaces),
3941
Single inheritance of implementation/multiple inheritance of interfaces,
4042
$(A spec/operatoroverloading.html, Operator overloading),
4143
$(A spec/module.html, Modules),
4244
No built-in dynamic class loading,
4345
$(A spec/class.html#nested, Nested classes),
4446
$(A spec/class.html#nested, Inner (adaptor) classes),
45-
$(A spec/function.html, Covariant return types),
46-
$(A spec/property.html#classproperties, Properties)
47+
$(A spec/function.html#covariance, Covariant return types),
48+
$(A spec/function.html#property-functions, Properties)
4749
),
4850
Performance
4951
$(ITEMIZE
@@ -54,43 +56,77 @@ $(ITEMIZE
5456
Independent of VM,
5557
Direct native code gen
5658
),
57-
$(A spec/template.html, Generic Programming)
59+
Generic Programming
5860
$(ITEMIZE
59-
Class Templates,
61+
$(A spec/declaration.html#AutoDeclaration, Implicit Type Inference),
62+
$(A spec/statement.html#ForeachStatement, `foreach`),
63+
$(MREF_ALTTEXT Ranges, std,range),
64+
$(MREF_ALTTEXT Algorithms, std,algorithm),
65+
$(A spec/declaration.html#alias, Aliases),
66+
$(A spec/template.html, Templates)
67+
$(ITEMIZE
68+
$(A spec/template.html#aggregate_templates, Aggregate Templates),
6069
$(A spec/template.html#function-templates, Function Templates),
61-
Implicit Function Template Instantiation,
62-
Partial and Explicit Specialization,
63-
Value Template Parameters,
64-
Template Template Parameters,
70+
$(A spec/template.html#ifti, Implicit Function Template Instantiation),
71+
$(A spec/template.html#parameters_specialization, Partial and Explicit Template Specialization),
72+
$(A spec/template.html#template_value_parameter, Value Template Parameters),
73+
$(A spec/template.html#aliasparameters, Alias Template Parameters),
6574
$(A articles/variadic-function-templates.html, Variadic Template Parameters),
66-
$(A concepts.html, Template Constraints),
75+
$(A articles/constraints.html, Template Constraints)
76+
)
77+
$(A spec/expression.html#IsExpression, `is` expressions),
78+
$(A spec/type.html#Typeof, `typeof`)
79+
),
80+
Metaprogramming
81+
$(ITEMIZE
82+
$(A spec/function.html#interpretation, Compile Time Function Evaluation),
6783
$(A spec/template-mixin.html, Template Mixins),
68-
$(A spec/version.html#staticif, static if),
69-
$(A spec/expression.html#IsExpression, expressions),
70-
$(A spec/type.html#Typeof, typeof),
71-
$(A spec/statement.html#ForeachStatement, foreach),
72-
$(A spec/declaration.html#AutoDeclaration, Implicit Type Inference)
84+
$(A articles/mixin.html, String Mixins),
85+
$(A spec/version.html#staticif, `static if`),
86+
$(A spec/version.html#staticforeach, `static foreach`)
7387
),
7488
Reliability
7589
$(ITEMIZE
7690
$(A spec/contracts.html, Contract Programming),
7791
$(A spec/unittest.html, Unit testing),
92+
$(A spec/const3.html, Immutable data),
93+
$(A spec/function.html#pure-functions, Pure functions),
7894
$(A spec/module.html#staticorder, Static construction order),
79-
$(A spec/statement.html#DeclarationStatement, Guaranteed initialization),
80-
$(A https://wiki.dlang.org/Memory_Management#RAII_.28Resource_Acquisition_Is_Initialization.29, RAII (automatic destructors)),
95+
$(A spec/declaration.html#initialization, Initialization by default),
96+
$(A spec/glossary.html#raii, RAII (implicit destructor calls)),
8197
$(A spec/statement.html#TryStatement, Exception handling),
8298
$(A spec/statement.html#ScopeGuardStatement, Scope guards),
83-
$(A spec/statement.html#TryStatement, try-catch-finally blocks),
99+
$(A spec/statement.html#TryStatement, `try`-`catch`-`finally` blocks),
100+
$(A articles/safed.html, Memory-safe subset)
101+
),
102+
Concurrency & Parallelism
103+
$(ITEMIZE
104+
$(MREF_ALTTEXT Concurrency, std,concurrency),
105+
$(MREF_ALTTEXT Fibers, core,thread,fiber),
106+
$(REF parallel, std,parallelism),
107+
$(A articles/migrate-to-shared.html, Thread Local Storage by default),
108+
$(A spec/const3.html#shared, Shared data),
84109
$(A spec/statement.html#SynchronizedStatement, Thread synchronization primitives)
85110
),
111+
Types
112+
$(ITEMIZE
113+
$(A spec/struct.html, Structs and Unions),
114+
$(A spec/enum.html, Enumerated types),
115+
$(A spec/float.html, 80 bit floating point),
116+
$(A phobos/std_complex.html, Complex and Imaginary),
117+
$(A spec/type.html#pointers, Pointers),
118+
$(REF_ALTTEXT Tuples, Tuple, std,typecons),
119+
$(A spec/struct.html#alias-this, Alias This)
120+
),
86121
Compatibility
87122
$(ITEMIZE
88123
C-like syntax,
89-
$(A spec/enum.html, Enumerated types),
90124
$(A spec/type.html, Support for all C types),
91-
$(A spec/type.html, 80 bit floating point),
92-
$(A phobos/std_complex.html, Complex and Imaginary),
125+
$(A spec/statement.html#NonEmptyStatementNoCaseNoDefault,
126+
`if`, `while`, `do`, `for`, `switch`, `goto`),
93127
$(A spec/attribute.html#linkage, Direct access to C),
128+
$(A spec/importc.html, Import C code),
129+
$(A spec/betterc.html, Better C subset),
94130
Use existing debuggers,
95131
$(A spec/attribute.html#align, Struct member alignment control),
96132
Generates standard object files,
@@ -100,7 +136,10 @@ $(ITEMIZE
100136
$(ITEMIZE
101137
$(A spec/version.html, Conditional compilation),
102138
$(A spec/lex.html, Unicode source text),
103-
$(A spec/ddoc.html, Documentation comments)
139+
$(A spec/statement.html#with-statement, `with` statement),
140+
$(A spec/attribute.html#UserDefinedAttribute, User-Defined Attributes),
141+
$(A spec/ddoc.html, Documentation comments),
142+
$(A spec/ddoc.html#using_ddoc_to_generate_examples, Documented unit tests)
104143
)
105144
)
106145

spec/arrays.dd

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,22 @@ int[]* e; // pointer to dynamic array of ints
107107
---------
108108
)
109109

110-
$(H2 $(LNAME2 literals, Array Literals))
110+
$(H2 $(LNAME2 literals, Array Initializers & Literals))
111111

112+
$(P An $(GLINK ArrayInitializer) initializes a dynamic or static array:)
112113
---
113114
auto a1 = [1,2,3]; // type is int[], with elements 1, 2, and 3
114115
auto a2 = [1u,2,3]; // type is uint[], with elements 1u, 2u, and 3u
115116
int[2] a3 = [1,2]; // type is int[2], with elements 1, and 2
116117
---
117-
$(P `[]` is an empty array literal.)
118118

119-
$(P See $(DDSUBLINK spec/expression, array_literals, Array Literals).)
119+
$(P An $(DDSUBLINK spec/expression, array_literals, array literal) is an expression:)
120+
---
121+
void f(int[] a);
122+
123+
f([1, 2]); // pass 2 elements
124+
f([]); // pass an empty array
125+
---
120126

121127
$(LEGACY_LNAME2 usage)
122128
$(H2 $(LNAME2 assignment, Array Assignment))
@@ -1010,14 +1016,29 @@ $(H3 $(LNAME2 void-initialization, Void Initialization))
10101016
$(REF uninitializedArray, std,array).
10111017
)
10121018

1019+
$(H3 $(LNAME2 array-initializers, Array Initializers))
10131020

1014-
$(H3 $(LNAME2 static-init-static, Static Initialization of Statically Allocated Arrays))
1021+
$(GRAMMAR
1022+
$(GNAME ArrayInitializer):
1023+
$(D [) $(I ArrayElementInitializers)$(OPT) $(D ])
1024+
1025+
$(GNAME ArrayElementInitializers):
1026+
$(I ArrayElementInitializer)
1027+
$(I ArrayElementInitializer) $(D ,)
1028+
$(I ArrayElementInitializer) $(D ,) $(GSELF ArrayElementInitializers)
1029+
1030+
$(GNAME ArrayElementInitializer):
1031+
$(GLINK2 declaration, NonVoidInitializer)
1032+
$(GLINK2 expression, AssignExpression) $(D :) $(GLINK2 declaration, NonVoidInitializer)
1033+
)
10151034

1016-
$(P Static initalizations are supplied by a list of array
1035+
$(P An *ArrayInitializer* is a list of array
10171036
element values enclosed in `[ ]`. The values can be optionally
10181037
preceded by an index and a `:`.
10191038
If an index is not supplied, it is set to the previous index
10201039
plus 1, or 0 if it is the first value.
1040+
Any missing elements will be initialized to the default value
1041+
of the element type.
10211042
)
10221043

10231044
$(SPEC_RUNNABLE_EXAMPLE_RUN
@@ -1043,6 +1064,26 @@ assert(value == [5, 6, 2]);
10431064
---------
10441065
)
10451066

1067+
$(P Any indices must be known at compile-time.
1068+
Note that if the array type is not specified and every element has an index,
1069+
it will be inferred as an
1070+
$(DDSUBLINK spec/expression, associative_array_literals, associative array
1071+
literal).)
1072+
1073+
$(SPEC_RUNNABLE_EXAMPLE_RUN
1074+
---
1075+
int n = 4;
1076+
auto aa = [0:1, 3:n]; // associative array `int[int]`
1077+
1078+
int[] a = [1, 3:n, 5];
1079+
assert(a == [1, 0, 0, n, 5]);
1080+
1081+
//int[] e = [n:2]; // error, n not known at compile-time
1082+
---
1083+
)
1084+
1085+
$(H3 $(LNAME2 static-init-static, Static Initialization of Statically Allocated Arrays))
1086+
10461087
$(P All elements of a static array can be initialized to a specific value with:)
10471088

10481089
$(SPEC_RUNNABLE_EXAMPLE_RUN
@@ -1281,43 +1322,57 @@ writefln("the string is '%s'", str);
12811322

12821323
$(H3 $(LNAME2 void_arrays, Void Arrays))
12831324

1284-
$(P There is a special type of array which acts as a wildcard that can hold
1285-
arrays of any kind, declared as $(D void[]). Void arrays are used for
1325+
$(P There are special types of array with `void` element type which can hold
1326+
arrays of any kind. Void arrays are used for
12861327
low-level operations where some kind of array data is being handled, but
12871328
the exact type of the array elements are unimportant. The $(D .length) of a
12881329
void array is the length of the data in bytes, rather than the number of
1289-
elements in its original type. Array indices in indexing and slicing
1290-
operations are interpreted as byte indices.)
1330+
elements in its original type. Array indices in slicing
1331+
operations are interpreted as byte indices. A void array cannot be indexed.)
12911332

1292-
$(P Arrays of any type can be implicitly converted to a void array; the
1333+
$(P Arrays of any type can be implicitly converted to a (tail qualified) void array - the
12931334
compiler inserts the appropriate calculations so that the $(D .length) of
12941335
the resulting array's size is in bytes rather than number of elements. Void
1295-
arrays cannot be converted back to the original type without using a cast,
1336+
arrays cannot be converted back to the original type without using an
1337+
$(DDSUBLINK spec/expression, cast_array, array cast),
12961338
and it is an error to convert to an array type whose element size does not
12971339
evenly divide the length of the void array.)
12981340

1299-
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
1341+
$(SPEC_RUNNABLE_EXAMPLE_RUN
13001342
---------
13011343
void main()
13021344
{
13031345
int[] data1 = [1,2,3];
1304-
long[] data2;
13051346

13061347
void[] arr = data1; // OK, int[] implicit converts to void[].
13071348
assert(data1.length == 3);
13081349
assert(arr.length == 12); // length is implicitly converted to bytes.
13091350

1310-
//data1 = arr; // Illegal: void[] does not implicitly
1351+
arr[0..4] = [5]; // Assign first 4 bytes to 1 int element
1352+
assert(data1 == [5,2,3]);
1353+
1354+
arr ~= [6]; // Append the 4 bytes of an int
1355+
//data1 = arr; // Error: void[] does not implicitly
13111356
// convert to int[].
1312-
int[] data3 = cast(int[]) arr; // OK, can convert with explicit cast.
1313-
data2 = cast(long[]) arr; // Runtime error: long.sizeof == 8, which
1357+
int[] data2 = cast(int[]) arr; // OK, can convert with explicit cast.
1358+
assert(data2 is arr); // both point to the same set of bytes
1359+
assert(data2 == [5,2,3,6]);
1360+
}
1361+
---------
1362+
)
1363+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
1364+
---------
1365+
void main()
1366+
{
1367+
void[] arr = new void[12];
1368+
long[] bad = cast(long[]) arr; // Runtime error: long.sizeof == 8, which
13141369
// does not divide arr.length, which is 12
13151370
// bytes.
13161371
}
13171372
---------
13181373
)
13191374

1320-
$(P Void arrays can also be static if their length is known at
1375+
$(P Void arrays can be static arrays if their length is known at
13211376
compile-time. The length is specified in bytes:)
13221377

13231378
$(SPEC_RUNNABLE_EXAMPLE_COMPILE

spec/attribute.dd

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ $(GNAME FunctionAttributeKwd):
3939

4040
$(GNAME AtAttribute):
4141
$(D @) $(RELATIVE_LINK2 disable, $(D disable))
42+
$(D @) $(RELATIVE_LINK2 future, $(D __future))
4243
$(D @) $(RELATIVE_LINK2 nogc, $(D nogc))
4344
$(D @) $(DDLINK spec/ob, Live Functions, `live`)
4445
$(GLINK Property)
@@ -402,6 +403,34 @@ $(GNAME DeprecatedAttribute):
402403
)
403404

404405

406+
$(H2 $(LNAME2 future, `@__future` attribute))
407+
408+
$(P The `@__future` attribute is used to mark a new symbol which could
409+
cause a name clash in another module. The other module using a symbol with the
410+
same name will continue to compile as before but will show a deprecation message.
411+
The message indicates that the new symbol will break the existing code in future,
412+
and the other module should be updated.
413+
)
414+
415+
$(NOTE Currently only methods that implicitly override a `@__future` base class
416+
method show a deprecation message.)
417+
418+
$(P See $(LINK2 https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1007.md,
419+
DIP1007) for details.)
420+
421+
$(COMMENT
422+
---
423+
module a;
424+
@__future int i;
425+
426+
module b;
427+
import a;
428+
import c : i;
429+
enum e = i; // Deprecation: `c.i` will conflict with `@__future` symbol `a.i`
430+
---
431+
)
432+
433+
405434
$(H2 $(LNAME2 visibility_attributes, Visibility Attributes))
406435

407436
$(GRAMMAR

0 commit comments

Comments
 (0)