Skip to content

[Design] lists are like c arrays #1

Description

@DavyLandman

In continuation of discussion with @jvdb, as references in metal are lists, we could model them as c arrays, where they are a pointer to the first element.

For example:

*x == x[0]

So if you want to do something with the whole list, you reference x, if you want to take the most recent element you can use either the * notation, or get the 0th element.

If you want to take the first, you use index -1. And we also add a syntax for ranges, like slices in golang, rascal, rust. ([start:stop] or [start:] or [: stop])

The most confusing part is the fact that the list are in a way reverse.

And the file offset is a bit strange, as &(*x) would be the cleanest. But that's strange, but maybe &x would also be unintuitive, as in c x would be the pointer you want to have. This gets more intuitive with the &(x[4]) syntax. So we could also drop the *x shorthand, and always write x[0].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions