microsoft / microsoft/typespec

[core] Mutator result caching

Open
#7,250 0 comments 0 reactions 0 assignees View on GitHub
compiler:core design:needed triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

After implementing mutator caching for the third time in one week, I'm starting to think this is something the core should do for us.

Essentially:
- A Mutator should be able to declare if it is "pure."
- The result of applying a "pure" Mutator to a type T multiple times (by object identity), should return an object-identical result if and only if `T` is _finished_.
- If `T` is not finished, mutator callers will be responsible for caching mutation results if they want, or we could provide another mechanism to select/filter types that should be cached in that circumstance.

Of course, nothing in the language will stop someone from mutating finished types, but please don't.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.