Skip to content

Add public scope() method to TemplateValues#77

Merged
SeanTAllen merged 1 commit intomainfrom
add-scope-method
Mar 13, 2026
Merged

Add public scope() method to TemplateValues#77
SeanTAllen merged 1 commit intomainfrom
add-scope-method

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

TemplateValues already supports parent-scoped lookup internally via the package-private _create constructor (used by _override for loop variables). scope() exposes this as a public API: it creates an empty writable child backed by the receiver as a read-only parent, so lookups that miss in the child fall through to the parent chain.

The motivating use case is livery's LiveView.render, where the backing TemplateValues is seen as box through viewpoint adaptation. scope() lets the view get a writable TemplateValues that inherits existing assigns without copying data or modifying the original.

Closes #76

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Mar 13, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Mar 13, 2026
TemplateValues already supports parent-scoped lookup internally via
_create (used by _override for loop variables). scope() exposes this
as a public API: it creates an empty writable child backed by the
receiver as a read-only parent, so lookups that miss in the child
fall through to the parent chain.

The motivating use case is livery's LiveView.render, where the
backing TemplateValues is seen as box through viewpoint adaptation.
scope() lets the view get a writable TemplateValues that inherits
existing assigns without copying data or modifying the original.

Also adds a docstring to the existing update() method, which was the
only public API element on TemplateValues without one.

Closes #76
@SeanTAllen SeanTAllen merged commit 7f7cd75 into main Mar 13, 2026
8 checks passed
@SeanTAllen SeanTAllen deleted the add-scope-method branch March 13, 2026 15:26
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Mar 13, 2026
github-actions Bot pushed a commit that referenced this pull request Mar 13, 2026
github-actions Bot pushed a commit that referenced this pull request Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - added Automatically add "Added" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add public child() method to TemplateValues

2 participants