feat[cartesian]: lazy annotated gtscript functions#2708
Open
romanc wants to merge 4 commits into
Open
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
romanc
force-pushed
the
romanc/lazy_functions
branch
from
July 16, 2026 15:29
a1b2f6a to
805945e
Compare
This PR extends the `gtscript` language by adding `lazy_function` next to `function`. `gtscript.lazy_funtion`s get annotated lazily, i.e. only when used inside a stencil that gets annotated. In addition, `gtscript.lazy_function`s give users hooks to optionally run code before and after the function gets annotated. This feature could be used to e.g. resolve temporary types that aren't fully defined yet when "normal" `gtscript.function`s get annotated.
romanc
force-pushed
the
romanc/lazy_functions
branch
from
July 17, 2026 08:11
82cce46 to
44c2252
Compare
romanc
marked this pull request as ready for review
July 17, 2026 08:12
Contributor
Author
|
Alright - this is ready for show now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR extends the
gtscriptlanguage with@gtscript.lazy_function()a decorator forgtscriptfunctions where the annotation is delayed until the function is actually used inside a stencil or another function.This allows support for types that aren't fully defined at the time when
gtscript.functions are parsed (i.e. python parse time) by leveraging a hook to inject the right type before annotation happens. Details, motivation, and an example usage are in the ADR.Tested in NDSL with PR NOAA-GFDL/NDSL#507.
Requirements