diff --git a/readme.md b/readme.md index 712142d..80ea1da 100644 --- a/readme.md +++ b/readme.md @@ -114,7 +114,11 @@ function declaration, an `impl` method definition, or a `::` type declaration positions are exempt**: a struct *field*, a union *tag*, and a protocol *method-signature* may be a bare reserved spelling (`struct { s2: s64 }`, `union { u8: … }`, `protocol { s2 :: (self) }`) — they are reached via `obj.name`, -so they never mis-lower. A leading backtick escapes one into a **raw identifier**: +so they never mis-lower. The bare exemption covers only the identifier-classified +reserved names (`s1`..`s64`, `u1`..`u64`, `bool`, `string`, `void`, `usize`, +`isize`, `Any`); `f32` and `f64` are lexer keywords, so even in a member slot they +need the backtick (`` struct { `f32: s64 } ``). A leading backtick escapes one into +a **raw identifier**: `` `name `` is the literal identifier `name` (the backtick drops out of the text), usable in **every** position — value, declaration, and type, and optional in the exempt member positions. It is the only way handwritten sx can spell a reserved diff --git a/specs.md b/specs.md index 583943e..3683a57 100644 --- a/specs.md +++ b/specs.md @@ -38,6 +38,15 @@ and `` obj.`s2 `` both resolve. The exemption covers member *signatures* only: a slot), so a reserved-spelled impl method still needs the backtick (`` `s2 :: (self) ``), exactly like a free function. See `examples/0158`. +The bare member-name exemption applies only to the **identifier-classified** +reserved spellings — `s1`..`s64`, `u1`..`u64`, `bool`, `string`, `void`, `usize`, +`isize`, `Any` — which all lex as ordinary identifiers. The two +**keyword-classified** reserved spellings, `f32` and `f64`, are lexer keywords, and +member-name slots require an identifier token; a bare `f32` / `f64` is therefore +rejected at parse (`expected field name in struct`) even in a member position. Use +the backtick there too — `` struct { `f32: s64; } `` / `` union { `f64: … } `` / +`` protocol { `f32 :: (self); } `` work as field / tag / method names. + ```sx s2 := 2.5; // ERROR: 's2' is a reserved type name and cannot be used as an identifier s2 :: 5; // ERROR — a `::` constant name is a binding site too