|
2 | 2 |
|
3 | 3 | ## Syntax |
4 | 4 |
|
5 | | -### Optional attribute |
6 | | - |
7 | 5 | [_fully_qualified_name_](fully_qualified_name.md) __(__ `(` [_argument_list_](argument_list.md) `)` __)?__ |
8 | 6 |
|
9 | | -### Required attribute |
| 7 | +## Semantics |
10 | 8 |
|
11 | | -[_fully_qualified_name_](fully_qualified_name.md) __(__ `(` [_argument_list_](argument_list.md) `)` __)?__ |
| 9 | +If the [_fully_qualified_name_](fully_qualified_name.md) is a single name, |
| 10 | +then this attribute is required. A required attribute must be handled by the compiler. |
| 11 | +If the compiler does not know how to handle the attribute it is an error. |
12 | 12 |
|
13 | | -## Semantics |
| 13 | +If the [_fully_qualified_name_](fully_qualified_name.md) has the `std` prefix |
| 14 | +it is a well-known optional attribute. These attributes don't change the semantic |
| 15 | +meaning of the program, instead they are directives to the compiler to create |
| 16 | +better code. |
| 17 | + |
| 18 | +Other prefixes are attributes that are handled by specific compilers. Compilers |
| 19 | +should ignore any attributes that do not match their own prefix. |
| 20 | + |
| 21 | +### abi() |
| 22 | +Make this function available for linking with an application written in a |
| 23 | +different language; using a different ABI (Application Binary Interface). |
| 24 | + |
| 25 | + - __c__: Use the C ABI. |
| 26 | + - __cpp__: Use the C++ ABI. |
| 27 | + |
| 28 | +### no_return |
| 29 | +This function will not return. |
| 30 | + |
| 31 | +An implementation must terminate the application if the function does |
| 32 | +return. Or proof that the function will not return. |
| 33 | + |
| 34 | +### pre() |
| 35 | +Pre-condition is checked before calling the function. |
| 36 | + |
| 37 | +### post() |
| 38 | +Post-condition is checked after calling the function. |
| 39 | + |
| 40 | + |
| 41 | +### std.no_inline |
| 42 | +Calls to this function are never inlined. |
| 43 | + |
| 44 | +This is a strong optimization lever: |
| 45 | + - It reduces code size by not inlining the code, which will reduce |
| 46 | + code-cache usage. |
| 47 | + - It significantly reduce register pressure, which will reduce the |
| 48 | + amount of reads/writes to memory. And may in turn reduce size of the |
| 49 | + code; which in turn may allow more inlining. |
| 50 | + |
| 51 | +### std.depricated, std.depricated() |
| 52 | +This function is depricated print a warning. A reason for deprication can |
| 53 | +be passed as a constant-string. |
| 54 | + |
| 55 | +### std.discard |
| 56 | +The return value of this function is allowed to be discarded by the caller. |
| 57 | + |
| 58 | +Discarding a return value is: |
| 59 | + - The return value is not assigned to a variable. |
| 60 | + - The return value is not passed to a function. |
| 61 | + - The return value is not part of a larger expression. |
| 62 | + - The return value is not used as an expression to a control-expression. |
| 63 | + |
| 64 | +If this attribute isn't set on a function, the compiler must give a warning |
| 65 | +when the function's return value is discarded. |
14 | 66 |
|
0 commit comments