Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/language-reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Contents
* [Lexical Structure](lexical-structure.md)
* [Preprocessor](preprocessor.md)
* [Types](types.md)
* [Generics](generics.md)
* [Expressions](expressions.md)
* [Statements](statements.md)
* [Declarations](declarations.md)
Expand Down
709 changes: 709 additions & 0 deletions docs/language-reference/generics.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/language-reference/types-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Restrictions for unknown-length arrays:
> avoid memory copies when possible, the compiler attempts to optimize these as pass by constant references or
> pointers when the target supports it.

> 📝 **Remark 5:** 0-length arrays can be used to disable data members in `struct` types. See [Generics (TODO)](TODO)
> 📝 **Remark 5:** 0-length arrays can be used to disable data members in `struct` types. See [Generics](generics.md)
> for further information.


Expand Down
4 changes: 2 additions & 2 deletions docs/language-reference/types-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- *`type-expr`* is the type to extend.
- *`generic-params-decl`* are the generic parameters for a [generic struct extension](#generic-struct).
- *`bases-clause`* is an optional list of [interface](types-interface.md) conformance specifications to be added.
- *`where-clause`* is an optional generic constraint expression. See [Generics (TODO)](TODO).
- *`where-clause`* is an optional [generic constraint expression](generics.md).
- *`member-list`* is a list of struct members to be added. A member is one of:
- *`var-decl`* is a member static variable declaration. See [Variables (TODO)](TODO)
- *`type-decl`* is a nested [type declaration](types.md).
Expand Down Expand Up @@ -174,4 +174,4 @@ extension<T : IBase> T
}
```

See [Generics (TODO)](TODO) for further information on generics.
See [Generics](generics.md) for further information on generics.
2 changes: 1 addition & 1 deletion docs/language-reference/types-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Associated named type declaration:

## Description

An `interface` specifies a set of member functions that a conforming type must provide. An interface can then
An `interface` specifies a set of members that a conforming type must provide. An interface can then
be used in place of a concrete type, allowing for the same code to use different concrete types via the
methods defined by the interface.

Expand Down
2 changes: 1 addition & 1 deletion docs/language-reference/types-pointer.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ See [type specifier syntax](types.md#syntax) for full type specifier syntax.
a [fundamental type](types-fundamental.md), [vector/matrix generic type](types-vector-and-matrix.md),
user-defined type such as a named [structure type](types-struct.md), [interface type](types-interface.md),
[enumeration type](types-enum.md), type alias, or a type provided by a module.
- *`generic-params-decl`* is a generic parameters declaration. See [Generics (TODO)](TODO).
- *`generic-params-decl`* is a [generic parameters declaration](generics.md).
- **`'['`** [*`constant-index-expr`*] **`']'`** is an [array dimension declaration](types-array.md) with an
optional constant integral expression specifying the dimension length.
- **`'*'`** is a [pointer declaration](types-pointer.md).
Expand Down
31 changes: 16 additions & 15 deletions docs/language-reference/types-struct.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Struct *no-body* declaration:
> *`struct-decl`* =<br>
> &nbsp;&nbsp;&nbsp;&nbsp;[*`modifier-list`*]<br>
> &nbsp;&nbsp;&nbsp;&nbsp;**`'struct'`** [*`identifier`*] [*`generic-params-decl`*]<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**`':'`** *`bases-clause`*] [**`'='`** *`type-expr`*] **`';'`**
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**`':'`** *`bases-clause`*] [**`'='`** *`simple-type-spec`*] **`';'`**

Struct *with-members* declaration:
> *`struct-decl`* =<br>
Expand All @@ -20,13 +20,13 @@ Struct *link-time extern type* declaration:
> *`struct-decl`* =<br>
> &nbsp;&nbsp;&nbsp;&nbsp;[*`modifier-list`*]<br>
> &nbsp;&nbsp;&nbsp;&nbsp;**`'extern'`** **`'struct'`** [*`identifier`*] [*`generic-params-decl`*]<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**`':'`** *`bases-clause`*] [**`'='`** *`type-expr`*] **`';'`**
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**`':'`** *`bases-clause`*] [**`'='`** *`simple-type-spec`*] **`';'`**

Struct *link-time export type alias* declaration:
> *`struct-decl`* =<br>
> &nbsp;&nbsp;&nbsp;&nbsp;[*`modifier-list`*]<br>
> &nbsp;&nbsp;&nbsp;&nbsp;**`'export'`** **`'struct'`** [*`identifier`*] [*`generic-params-decl`*]<br>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**`':'`** *`bases-clause`*] **`'='`** *`type-expr`* **`';'`**
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[**`':'`** *`bases-clause`*] **`'='`** *`simple-type-spec`* **`';'`**

Member list:
> *`member-list`* =<br>
Expand All @@ -42,10 +42,10 @@ Member list:

- *`modifier-list`* is an optional list of modifiers (TODO: link)
- *`identifier`* is an optional name of the declared struct type
- *`generic-params-decl`* is an optional generic parameters declaration. See [Generics (TODO)](TODO).
- *`generic-params-decl`* is an optional generic parameters declaration. See [generics](generics.md).
- *`bases-clause`* is an optional list of inherited [interfaces](types-interface.md).
- *`type-expr`* is an optional type expression for an alias type. See [Modules (TODO)](TODO).
- *`where-clause`* is an optional generic constraint expression. See [Generics (TODO)](TODO).
- *`simple-type-spec`* is an optional type expression for an alias type. See [Modules (TODO)](TODO).
- *`where-clause`* is an optional generic constraint expression. See [generics](generics.md).
- *`member-list`* is a list of struct members. A member is one of:
- *`var-decl`* is a member variable declaration. See [Variables (TODO)](TODO)
- *`type-decl`* is a nested [type declaration](types.md).
Expand Down Expand Up @@ -141,10 +141,10 @@ An object is an *instance* of a `struct`. An instance consists of all non-static
### Syntax

Declaration without body: (interfaces only)
> **`'__init'`** **`'('`** *`param-list`* **`')'`** (**`'where'`** *`where-clause`*)\* **`';'`**
> **`'__init'`** [*`generic-params-decl`*] **`'('`** *`param-list`* **`')'`** (**`'where'`** *`where-clause`*)\* **`';'`**

Declaration with body:
> **`'__init'`** **`'('`** *`param-list`* **`')'`** (**`'where'`** *`where-clause`*)\*<br>
> **`'__init'`** [*`generic-params-decl`*] **`'('`** *`param-list`* **`')'`** (**`'where'`** *`where-clause`*)\*<br>
> &nbsp;&nbsp;&nbsp;&nbsp;**`'{'`** *`body-stmt`*\* **`'}'`**


Expand All @@ -163,7 +163,7 @@ instantiation.

`const` data members cannot be initialized by the constructor.

*`where-clause`* is an optional generic constraint expression, discussed in [Generics (TODO)](TODO).
*`where-clause`* is an optional generic constraint expression, discussed in [generics](generics.md).


**Example:**
Expand Down Expand Up @@ -269,10 +269,10 @@ Non-static member functions cannot be invoked without an object.
### Syntax

Modern syntax, implicit `get` declaration: (interfaces only)
> **`'property'`** *`identifier`* **`':'`** *`type-expr`* **`';'`**
> **`'property'`** *`identifier`* **`':'`** *`simple-type-spec`* **`';'`**

Modern syntax, explicit accessor declarations:
> **`'property'`** *`identifier`* **`':'`** *`type-expr`*<br>
> **`'property'`** *`identifier`* **`':'`** *`simple-type-spec`*<br>
> **`'{'`** *`accessor-decl`*\* **`'}'`**

Traditional syntax, implicit `get` declaration: (interfaces only)
Expand Down Expand Up @@ -471,10 +471,10 @@ int tmp4 = TestStruct::incrementAndReturnB();
### Syntax

Implicit `get` declaration: (interfaces only)
> **`'__subscript'`** [**`'('`** *`param-list`* **`')'`**]<br>
> **`'__subscript'`** **`'('`** *`param-list`* **`')'`** **`'->'`** *`simple-type-spec`* **`';'`**

Explicit accessor declarations:
> **`'__subscript'`** [**`'('`** *`param-list`* **`')'`**] **`'->'`** *`type-expr`*<br>
> **`'__subscript'`** **`'('`** *`param-list`* **`')'`** **`'->'`** *`simple-type-spec`*<br>
> **`'{'`** *`accessor-decl`*\* **`'}'`**

See [properties](#property) for *`accessor-decl`* syntax.
Expand Down Expand Up @@ -532,6 +532,7 @@ struct TestStruct
}
}

[numthreads(1,1,1)]
void main(uint3 id : SV_DispatchThreadID)
{
TestStruct x = { };
Expand All @@ -551,10 +552,10 @@ void main(uint3 id : SV_DispatchThreadID)
### Syntax

Declaration without body: (interfaces only)
> *`type-expr`* **`'operator'`** **`'(' ')'`** **`'('`** *`param-list`* **`')'`** **`';'`**
> *`simple-type-spec`* **`'operator'`** **`'(' ')'`** **`'('`** *`param-list`* **`')'`** **`';'`**

Declaration with body:
> *`type-expr`* **`'operator'`** **`'(' ')'`** **`'('`** *`param-list`* **`')'`**<br>
> *`simple-type-spec`* **`'operator'`** **`'(' ')'`** **`'('`** *`param-list`* **`')'`**<br>
> **`'{'`** *`body-stmt`*\* **`'}'`**

### Description
Expand Down
6 changes: 3 additions & 3 deletions docs/language-reference/types-vector-and-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A `vector<T, N>` represents a vector of `N` elements of type `T` where:
- `T` is a [fundamental scalar type](types-fundamental.md)
- `N` is a [specialization-time constant integer](TODO-Generics.md) in range [1, 4] denoting the number of elements.
- `N` is an [instantiation-time constant integer](generics.md) in range [1, 4] denoting the number of elements.

The default values for `T` and `N` are `float` and `4`. This is for backwards compatibility.

Expand Down Expand Up @@ -116,8 +116,8 @@ The alignment of a vector type is target-defined. The alignment of `vector<T, N>

Type `matrix<T, R, C>` represents a `R`×`C` matrix of elements of type `T` where:
- `T` is a [fundamental scalar type](types-fundamental.md)
- `R` is a [specialization-time constant integer](TODO-Generics.md) in range [1, 4] denoting the number of rows.
- `C` is a [specialization-time constant integer](TODO-Generics.md) in range [1, 4] denoting the number of columns.
- `R` is an [instantiation-time constant integer](generics.md) in range [1, 4] denoting the number of rows.
- `C` is an [instantiation-time constant integer](generics.md) in range [1, 4] denoting the number of columns.

The default values for `T`, `R`, `C` are `float`, `4`, `4`. This is for backwards compatibility.

Expand Down
8 changes: 4 additions & 4 deletions docs/language-reference/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ Full type specifier, possibly declaring a new type:
a [fundamental type](types-fundamental.md), [vector/matrix generic type](types-vector-and-matrix.md),
user-defined type such as a named [structure type](types-struct.md), [interface type](types-interface.md),
[enumeration type](types-enum.md), type alias, or a type provided by a module.
- *`generic-params-decl`* is a generic parameters declaration. See [Generics (TODO)](TODO).
- *`generic-params-decl`* is a [generic parameters declaration](generics.md).
- **`'['`** [*`constant-index-expr`*] **`']'`** is an [array dimension declaration](types-array.md) with an
optional constant integral expression specifying the dimension length.
- **`'*'`** is a [pointer declaration](types-pointer.md).
- *`param-list`* is a function parameter list. See [function parameter list (TODO)](TODO).
- *`struct-decl`* is a [structure](types-struct.md) type declaration, possibly also defining the type.
- *`class-decl`* is a [class (TODO)](types-class.md) type declaration, possibly also defining the type.
- *`enum-decl`* is an [enumeration (TODO)](types-enum.md) type declaration, possibly also defining the type.
- *`enum-decl`* is an [enumeration](types-enum.md) type declaration, possibly also defining the type.


### Description
Expand All @@ -91,7 +91,7 @@ specifiers are used in:
- [function return value type (TODO)](TODO) declarations
- [structure property](types-struct.md#property)
- [structure subscript operator](types-struct.md#subscript-op)
- [generic type parameter declarations (TODO)](TODO)
- [generic type parameter declarations](generics.md)
- [typealias](#alias) declarations

Declaration of new types is allowed in:
Expand Down Expand Up @@ -137,7 +137,7 @@ A `typealias` declaration introduces a name for a type. A `typedef` declaration
also allows declaring a new type.

A generic type alias declaration declares a parameterized alias for a generic type. This is described in
[Generics (TODO)](TODO).
[Generics](generics.md).


## Complete and Incomplete Types {#incomplete}
Expand Down