docs: clarify Claro v1 status and validation
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# Advanced Static Typing
|
||||
|
||||
Claro v1.18.26 adds the first advanced static-typing foundation: typed containers checked by `claro typecheck`.
|
||||
|
||||
## Typed lists
|
||||
|
||||
```claro
|
||||
SET names AS LIST OF TEXT TO LIST
|
||||
ADD "Ada" TO names
|
||||
ADD "Grace" TO names
|
||||
```
|
||||
|
||||
The type checker now rejects wrong item types:
|
||||
|
||||
```claro
|
||||
SET names AS LIST OF TEXT TO LIST
|
||||
ADD 123 TO names
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```text
|
||||
Type mismatch for list names: expected TEXT item, but this value looks like NUMBER.
|
||||
```
|
||||
|
||||
## Typed maps
|
||||
|
||||
```claro
|
||||
SET scores AS MAP OF NUMBER TO MAP
|
||||
PUT scores KEY "math" VALUE 98
|
||||
```
|
||||
|
||||
The type checker rejects wrong value types:
|
||||
|
||||
```claro
|
||||
SET scores AS MAP OF NUMBER TO MAP
|
||||
PUT scores KEY "oops" VALUE "high"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```text
|
||||
Type mismatch for map scores: expected NUMBER value, but this value looks like TEXT.
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
This is currently a static checker feature. It improves `claro typecheck` and validation confidence. Runtime enforcement for every container mutation can be added later after the syntax is classroom-tested.
|
||||
Reference in New Issue
Block a user