[go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request #1987 from xushiwei/q
Browse files Browse the repository at this point in the history
mini spec: func
  • Loading branch information
xushiwei authored Sep 24, 2024
2 parents bfce240 + 252295f commit cda71cd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion doc/spec-mini.md
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,26 @@ println

## Functions

TODO
A function declaration binds an identifier, the function name, to a function.

```go
FunctionDecl = "func" FunctionName Signature [ FunctionBody ] .
FunctionName = identifier .
FunctionBody = Block .
```

If the function's [signature](#function-types) declares result parameters, the function body's statement list must end in a [terminating statement](#terminating-statements).

```go
func IndexRune(s string, r rune) int {
for i, c := range s {
if c == r {
return i
}
}
// invalid: missing return statement
}
```

## Packages

Expand Down

0 comments on commit cda71cd

Please sign in to comment.