Skip to content

Commit

Permalink
Add types in function declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
masak committed May 22, 2024
1 parent 7010f9d commit 2201b3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spec/02-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ A _function constructor_ creates a new function value.
<function-constructor> ::= "func"
<identifier>?
"(" <parameter-list> ")"
(":" <type>)?
<block>
```

It's important to note that the `func` keyword is also used for function
declarations (see [Chapter 4: Declarations](04-declarations.md)); in situations
where the `func` keyword could either be the start of a function declaration or
a function constructor, it's always a function declaration.
The `func` keyword is also used for function declarations (see [Chapter 4:
Declarations](04-declarations.md)); in situations where the `func` keyword
could either be the start of a function declaration or a function constructor,
it's always a function declaration.

The function name is optional in a function constructor. If supplied, that
name is visible in the parameter list and body of the function, but not outside
Expand Down
9 changes: 9 additions & 0 deletions spec/04-declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ connection with instances of the class.

## 4.2 Function declaration

```
<function-declaration> ::= "func"
<identifier>
"(" <parameter-list> ")"
(":" <type>)?
<block>
<semicolon>
```

## 4.3 Macro declaration

## 4.4 Class declaration
Expand Down

0 comments on commit 2201b3a

Please sign in to comment.