Skip to content

Conversation

@mohammadfawaz
Copy link
Contributor

@mohammadfawaz mohammadfawaz commented Jul 10, 2023

Closes #72

Fairly simple change:

  • Tuple types
  • Tuple expressions
  • Tuple indexing expressions. Error out on invalid indices such as 0xa or anything that is not a usize.

Note that t.0.0 does not currently work, but t.0 .0. Once we implement #66, we can then write (t.0).0. In the future, we can support t.0.0 which can be done in two ways:

@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/72 branch 4 times, most recently from fdeb90d to 61f3301 Compare July 10, 2023 19:38
@mohammadfawaz mohammadfawaz self-assigned this Jul 10, 2023
@mohammadfawaz mohammadfawaz marked this pull request as ready for review July 10, 2023 19:39
@mohammadfawaz mohammadfawaz changed the title tuples Parse tuple types and expressions Jul 10, 2023
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/72 branch 2 times, most recently from 969a9bc to 3a09819 Compare July 11, 2023 18:41
},
Block(Block),
If(IfExpr),
Tuple(Vec<Expr>),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a tuple a kind of immediate or literal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have something more complex such as:

let tuple = (
    { ... }, // code block
    if cond { .. } else { .. }, // if expressions
    foo(), // function call,
    etc.
);

I suppose adding tests for these would be quite useful.

sezna
sezna previously approved these changes Jul 11, 2023
Copy link

@sezna sezna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved but curious if a tuple could be a literal

Tuple indexing expressions are written as:

```ebnf
<tuple-index-expr> ::= <expr-atom> "." [0-9]+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's an expr-atom? It can be any expression which has a tuple type, which might be a fn call, identifier or other tuple index. So it should just be expr?

Copy link
Contributor Author

@mohammadfawaz mohammadfawaz Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I will restructure this. See #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse tuple types, tuple literals, tuple expressions, and tuple indexing expressions

4 participants