Replies: 2 comments 1 reply
-
We've hit a CUE bug doing so, using definitions to pass inputs is the right way to do it. For context see: |
Beta Was this translation helpful? Give feedback.
-
I think I found part of my answer here in the language reference on struct closure
So a hidden fields are really only meant for internal reference in a struct, e.g. intermediate values. I had only understood that hidden fields influence the struct generation/outputs and not the inputs as well. I guess that is useful because you can unify something and add your own hidden fields for intermediate values not supported already. So definitions as "arguments" is the only remaining option since it can be referenced externally and doesn't influence what the return values would be, since a non-definition value would have to be exported. |
Beta Was this translation helpful? Give feedback.
-
I wanted to share some very important "tricks" I'm coming across when working with Cue. Of course we can defer to that project but I think it would be beneficial to have some that are especially helpful in the context of Timoni.
I'll start off with this page in their docs: https://cuelang.org/docs/concept/alias-and-reference-scopes/
This was a very confusing error to get so I'm glad I found this!
The problem is that to implement modularity in Cue you kind of have this pattern that roughly approximates a function call:
This looks like it should work but instead you get this error:
Furthermore you have this problem where the names of the arguments conflict.
#thisConfig
shouldn't have to be distinguished from the inner#config
of#SubThing
. At least coming from function based languages this kind of a basic primitive.The solution is aliases:
Visually this also kind of distinguishes definitions that aren't part of the "arguments" and solves all the above problems.
This also shows a little style thing to distinguish abstract and concrete definitions using the first capitalization. Lower for concrete and capital for abstract "types".
What I don't quite understand is whether
#config
should just be a hidden key like_config
. It seems to me that one of the reasons I am using a definition is to stop it from being exported. I.e. separating the return values from the inputs and "stack" variables.Thoughts? Improvements I can make?
Beta Was this translation helpful? Give feedback.
All reactions