From 77d2f8a44e2503796a7ef5c170e11811a4f7fcfd Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 16:58:59 +0330 Subject: prototypes: parameters may be unnamed, int f(int, int*); (appendix b.2.13) --- docs/SPEC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/SPEC.md b/docs/SPEC.md index 30d547d..128f961 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -683,7 +683,7 @@ node*.u make() { ... } // owned result (.u) fn f(a, b) { ... } // untyped; types are inferred fn f(int a, b) { ... } // parameters may mix T first(T* p) { ... } // generic -int proto(int n); // prototype (parameter names are required) +int proto(int n); // prototype (int proto(int); also works: a prototype's parameter names are optional) ``` a bare `name(params) { ... }` with no `fn` and no type is not a function declaration (error: expected a declaration). @@ -1116,7 +1116,7 @@ each item gives a minimal program, the expected behavior (per this spec) and the 10. a syntax error hides errors in the statements skipped by recovery: `int a = ; int b = 3 +;` reports only the first error (8.2). by design, but easy to miss. 11. fixed (1.2.2): an unterminated `/* ...` comment was accepted silently; it is error: unterminated comment. (an unterminated string literal is still only reported as a later syntax error.) 12. settled (3.2.3): `x as int * y` parses `int*` as the type. this is the rule (the type is read greedily, as zc0 does too), so the program is a syntax error. -13. prototypes need parameter names: `int f(int);` => `expected a name, found ')'`. +13. fixed (5.2.1): a prototype's parameters may be unnamed (`int f(int, int*);`). a lone type name counts as a type only in a prototype; with a body it is still the parameter's name, and an unnamed typed parameter there is `a parameter needs a name`. 14. `len(s)` on a `char*` returns word 0 of the string when `typecheck` is off. 15. duplicate `case` labels are not diagnosed (4.7.2). 16. a local `const` cannot be used in a constant expression (b.1.7). -- cgit v1.2.3