WerWolv / WerWolv/PatternLanguage

[Feature] Default template arguments

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

Nobody has claimed this yet.

Dominant language
C++
Stars
275
Forks
75
Avg merge
1d 22h
Merged PRs (30d)
10

Description

What feature would you like to see?

Overrideable default values for template arguments like in C++.

struct Array<T = u32, auto Size = 10> {
  T data[Size];
};
How will this feature be useful to you and others?

I have a large number of "optional" structs in my patterns

struct Optional<T, U> {
    U isSome;
    if (isSome != 0) {
        T data;
    }
};

99% of the time U is a u8, but sometimes it is a u32. It would be nice to only have to specify U in the rare case rather than every time.

struct Optional<T, U = u8> {
    U isSome;
    if (isSome != 0) {
        T data;
    }
};

Optional<SomeOtherStruct> common_optional @ 0x00;
Optional<SomeOtherStruct, u32> uncommon_optional @ 0x10;
Request Type
  • I can provide a PoC for this feature or am willing to work on it myself and submit a PR
Additional context?

No response

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

The issue defines the requested default-template syntax through the Array and Optional examples, but names no source files, tests, or parser entry points. Start by locating the template parsing and type-resolution code, then identify existing tests for template arguments. Done means omitted arguments use their declared defaults while explicitly supplied arguments still override them.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.