-
By my reading of the CUE specification, a let declaration occurring at the top level of a file in a package should be scoped to the package. The "Declarations and scope" section of the specification says that
It clarifies that aliases occurring at the top level are scoped to the containing file, but it doesn't mention a similar restriction for let declarations. In my experiments with CUE version 0.4.0, though, I find that a let declaration is only visible within the containing file, and not in another file within the same package. If instead I replace the let declaration with a top-level field, I can refer to it from other files within the same package. Is my interpretation of the specification wrong? Is the CUE tool enforcing the wrong scope? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Based on experience with similar constructs in other languages, I find the CUE tool's file-scoped enforcement to make more sense, because let declarations seem like lexical elements to me, intended to be confined as locally as possible, to only where referring expressions can "see" the declaration. Should we tighten the specification's language accordingly? |
Beta Was this translation helpful? Give feedback.
-
This discussion has been migrated to cue-lang/cue#1041. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
Based on experience with similar constructs in other languages, I find the CUE tool's file-scoped enforcement to make more sense, because let declarations seem like lexical elements to me, intended to be confined as locally as possible, to only where referring expressions can "see" the declaration. Should we tighten the specification's language accordingly?