[Feature Request] Allow parametric materialization
Nobody has claimed this yet.
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Review Mojo's priorities
- I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
Allow parametric materialization of nonmaterializable types.
Currently, i'm not aware of any way to get the following behavior:
@nonmaterializable(MyVal[param])
struct MyLit[param: Bool]:
...
struct MyVal[param: Bool]:
...
Or alternatively, a required __materialize__() method when no arguments to @nonmaterializable are given:
@nonmaterializable
struct MyLit[param: Bool]:
fn __materialize__(self) -> MyVal[param]:
return self
...
struct MyVal[param: Bool]:
...
What is your motivation for this change?
I have some use cases for something like this, such as custom generalized complex literals.
I don't know the inner workings, so i'm not sure if this would fit into the compilation flow, but if not that's okay.
Any other details?
if something already exists like this, or you think there's a better way to go about it, let me know :]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by searching the Mojo compiler for handling of @nonmaterializable and materialization, then trace how parameterized types and generalized literals are represented. The issue provides no file or test entry point, so first identify the relevant compiler tests. Done means a parametric MyLit can materialize to MyVal[param], with coverage for the example behavior.
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
- Mostly clear
- Newbie friendliness
- 35/100