quick sort
This commit is contained in:
30
specs.md
30
specs.md
@@ -135,7 +135,7 @@ v1.x = 3.0; // assign to field x of struct v1
|
||||
#### Struct Interpolation
|
||||
Struct values in string interpolation print as `TypeName{field:value, ...}`:
|
||||
```sx
|
||||
print("{v1}"); // Vec4{x:1.0, y:2.0, z:3.0, w:0.0}
|
||||
print("{}", v1); // Vec4{x:1.0, y:2.0, z:3.0, w:0.0}
|
||||
```
|
||||
|
||||
### Union Types (Tagged Unions)
|
||||
@@ -174,7 +174,7 @@ if s == {
|
||||
#### Union Interpolation
|
||||
Union values in string interpolation print as `<TypeName tag=N>`:
|
||||
```sx
|
||||
print("{s}"); // <Shape tag=0>
|
||||
print("{}", s); // <Shape tag=0>
|
||||
```
|
||||
|
||||
### Array Types
|
||||
@@ -184,6 +184,22 @@ buffer : [5]f32 = .[0, 2, 3.5, 4, 0];
|
||||
val := buffer[2]; // 3.5
|
||||
```
|
||||
|
||||
### Slice Types
|
||||
A slice `[]T` is a fat pointer `{ptr, i32}` referencing a contiguous sequence of `T` elements. Same runtime layout as `string`.
|
||||
```sx
|
||||
// Arrays implicitly coerce to slices at call sites
|
||||
arr : [5]s32 = .[3, 1, 4, 1, 5];
|
||||
sortSlice(arr); // [5]s32 → []s32 coercion
|
||||
|
||||
// Slice operations
|
||||
items[i] // read element at index
|
||||
items[i] = val; // write element at index
|
||||
items.len // length (s32)
|
||||
items.ptr // raw pointer
|
||||
```
|
||||
|
||||
Slices support generic type parameters: `[]$T` introduces type parameter `T` inferred from the element type of the argument (array or slice).
|
||||
|
||||
### Vector Types (SIMD)
|
||||
LLVM SIMD vectors, parameterized by length and element type.
|
||||
```sx
|
||||
@@ -575,16 +591,6 @@ Used for module access (`std.print`) and struct member access.
|
||||
```
|
||||
The enum type is inferred from context (expected type from declaration or parameter).
|
||||
|
||||
### String Interpolation
|
||||
Curly braces inside string literals interpolate expressions:
|
||||
```sx
|
||||
"z: {z}"
|
||||
```
|
||||
The expression inside `{}` is evaluated and formatted according to its type:
|
||||
- `s32` — decimal integer
|
||||
- `f64` — decimal float
|
||||
- `string` — as-is
|
||||
|
||||
---
|
||||
|
||||
## 5. Statements
|
||||
|
||||
Reference in New Issue
Block a user