pc2 / pc2/sus-compiler

Should structs use existing module generative code system?

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

Nobody has claimed this yet.

Language Design
Dominant language
Rust
Stars
126
Forks
6
PR merge metrics
No merged PRs in 30d

Description

So I've been looking to add structs to SUS. But I'm not entirely convinced by my current approach.

Basically, I had the idea of integrating struct declarations with the existing SUS generative code system, but instead of

A regular struct looks pretty unassuming:

struct MyVec3 {
    int x
    int y
    int z
}

And having the generative code would allow for templated structs like

struct MyVec<T> {
    input gen int SIZE
    
    T[SIZE] arr
}

And even structs with optional fields like

struct BRAMRead<T> {
    input gen bool ECC_INCLUDED
    
    T read_data
    if ECC_INCLUDED { // (compiletime)
        bool ecc_did_error
    }
}

The idea here is that any non-gen (compiletime) declaration is interpreted as a struct field, whereas gen declarations (like the template parameters), are executable compile-time code.

While this is easy to implement, and even gains a little bonus for language consistency, I can't help but fear I might be shooting myself in the foot somehow.

Contributor guide

Open the contributing guide

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

No files or tests are named. Start by reading the existing SUS generative code system and its handling of compile-time declarations, then assess how regular, templated, and conditionally shaped structs should interact with it. Done means a decided design with documented semantics and an agreed implementation scope.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.