Skip to content

Implement Slices - struct elements only #31

@GraphR00t

Description

@GraphR00t

Inox slices are equivalent to Go slices. They are the primary way to create a sequence containing instances of a struct type.
Slices are not serializable.

struct Token {
    kind int
    start int
    end int
}

# allocate and initialize a slice of length 3 on the module's heap
tokens = [:]Token{{0, 3, 4}}

# allocate a slice on the module's heap
tokens = new([:]Token, 10)

# append a token at the end of the slice, should it work like Golang's append ?
tokens = appendto(tokens, Token{0, 3, 4})

# equivalent
appendto(&tokens, Token{0, 3, 4})

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