Skip to content

composite.md L8 conflates T[] (dynamic slice) with T[N] (fixed-size array) #20

Description

@davidfrogley

Summary

Web/src/docs/types/composite.md:8 describes T[] and T[N] together as "A fixed-size slice of N elements of type T":

| T[], T[N] | A fixed-size slice of N elements of type T |

T[N] is a fixed-size array, but T[] is a dynamic-length slice — the runtime layout is {data: *T, length: uint} and length is a runtime value, not a compile-time constant. The two forms have different semantics and the table description fits only the second.

Compiler reality

Rux/Include/Rux/Type.h:40 defines Kind::Slice with inner[0] as the element type and no compile-time length. The stdlib relies on the dynamic case throughout — e.g. Std/Src/String.rux:39:

func From(slice: char8[]) -> String {
    let len = slice.length;       // runtime field, not a compile-time constant
    ...
}

If T[] were really fixed-size-N, slice.length wouldn't be a meaningful runtime read.

Suggested fix

Split the row, or keep one row but name both behaviors:

| T[] | A dynamic-length slice (data pointer + runtime length) |
| T[N] | A fixed-size array of N elements of type T |

or:

| T[], T[N] | A slice (T[], dynamic length) or fixed-size array (T[N]) of T |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions