vx-lang / vx-lang/Vx

comptime · phase 4: growable values in the evaluator

Open
#575 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core-lang enhancement
Dominant language
Rust
Stars
14
Forks
2
Avg merge
12h 42m
Merged PRs (30d)
61

Description

Phase 4 of compile-time values, after #562 (fixed-size arrays of scalars), #573 (structs) and
#574 (multi-dimensional arrays).

Scope

A value that grows during compilation: a Vec built by pushing, so compile-time code can
produce a table whose length it works out rather than one written down in advance.

Every phase so far has a length fixed at construction. That is enough to sort a known number of
elements, and not enough to collect, filter, or build a table whose size depends on the data.

In scope

  • A growable variant in Value, or a length that is allowed to change on the existing array.
  • Vec::new() at compile time.
  • push and pop, and len as a compile-time value.
  • Indexing the result, which #562 already covers once the value exists.

Why this one is last

Vec is a library type whose operations are methods, and the evaluator has no arm for a method
call at all -- see #560, which this is blocked on. Until a method call is evaluated, v.push(x)
cannot do anything at compile time no matter what Value can hold.

There is also a design question worth settling before any code: whether growth belongs in the
evaluator at all, or whether compile-time code should be restricted to fixed sizes and produce a
fixed-size array as its result. A bound on total allocation matters here for the same reason a
recursion limit does in #561 -- a compile-time loop that pushes without end should be a
diagnostic, not a compiler that grows until the machine stops.

The rule this has to keep

The one from #562. Any operation the evaluator cannot carry out drops the value rather than
leaving stale contents readable. Growth widens the ways that can happen: a push whose argument
is unknown, a pop on a vector of unknown length.

Tests to add

  • Build by pushing, read back by index, with a false assert so the fixture can go red.
  • len after a known number of pushes, asserted.
  • A push the evaluator cannot compute, checked with a pair of contradictory asserts that are
    both expected to be accepted.
  • Unbounded growth, once the limit exists, checking for the diagnostic rather than a hang.

Related: #562, #573, #574, #560, #561.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the method-call evaluator work in #560 and the fixed-size compile-time value behavior from #562. Decide whether growth belongs in Value or the evaluator, including an allocation limit and unknown-value handling. Done means Vec::new(), push, pop, len, indexing, and the listed contradictory, false-assert, and unbounded-growth tests behave as specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.