Memoize default values in Schema, not Field
Surely this won't break anything...
PR Checklist (not all items are relevant to all PRs)
- [ ] Added unit-tests (for runtime code)
- [ ] Added bootstrapped code + smoke tests (when the rendering logic is modified)
- [ ] Added build-plugins integration tests (when reflection loading is required at codegen-time)
- [ ] Added alloy compliance tests (when simpleRestJson protocol behaviour is expanded/updated)
- [ ] Updated dynamic module to match generated-code behaviour
- [ ] Added documentation
- [ ] Updated changelog
can you elaborate on the why ?
I would prefer to have Option[() => A] instead (kind of evaluator function without any memorization) because instantiation of default values can be side effecting or the result value could be just mutable and should not be shared.
can you elaborate on the why ?
@Baccata I think it could be surprising that default values would get memoized in one place but not in another. My assumption is that the current behavior may not have been intentional, but maybe that's mistaken
I would prefer to have
Option[() => A]instead (kind of evaluator function without any memorization) because instantiation of default values can be side effecting or the result value could be just mutable and should not be shared.
there should be no side effects in instantiation of defaults from generated code. The only way I see it happening would be if you use a refinement to a mutable type, and that's probably already broken in several ways...