Skip to content

Commit 8bc2b9d

Browse files
committed
Add callable parameter attributes
1 parent e8ca5d4 commit 8bc2b9d

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Writerside/labels.list

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
<secondary-label id="wip" name="WIP" color="red">Work in progress</secondary-label>
2323
<secondary-label id="beta" name="β" color="tangerine">Beta</secondary-label>
2424
<secondary-label id="1.1" name="TypeLang 1.1" color="strawberry">Since type-lang/parser v1.1</secondary-label>
25+
<secondary-label id="1.2" name="TypeLang 1.2" color="strawberry">Since type-lang/parser v1.2</secondary-label>
2526
</labels>

Writerside/topics/language/callable-types.md

+46
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,49 @@ _before the type_ or _before the parameter name._
231231
232232
</tab>
233233
</tabs>
234+
235+
236+
## Attributes
237+
238+
<secondary-label ref="1.2"/>
239+
240+
Each callable parameter allows you to define list of additional attributes.
241+
An attribute is additional metadata for a parameter.
242+
243+
<tabs>
244+
<tab title="Examples">
245+
246+
> Simple attribute with one argument for each callable parameter.
247+
> ```typescript
248+
> Example\Functor(#[type<int8>] int $a): void
249+
> ```
250+
251+
> Multiple attributes in one group.
252+
> ```typescript
253+
> Example\Functor(#[type<int8>, const] int&): void
254+
> ```
255+
256+
> Multiple attribute groups.
257+
> ```typescript
258+
> Example\OnCreate(
259+
> #[deprecated]
260+
> #[inline]
261+
> (callback(T): void) $callback=,
262+
> ): void
263+
> ```
264+
265+
</tab>
266+
<tab title="Counterexamples">
267+
268+
> Only valid identifiers are allowed.
269+
> ```typescript
270+
> Example\Functor(#[42] int $a): void
271+
> ```
272+
> ```
273+
> Syntax error, unexpected "42"
274+
> ```
275+
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
276+
> {style="warning"}
277+
278+
</tab>
279+
</tabs>

0 commit comments

Comments
 (0)