-
Notifications
You must be signed in to change notification settings - Fork 171
Index into a struct to access a #Definition #421
Comments
This GitHub repo has access to the pre-beta Discussions https://github.com/cuelang/cue/discussions That will be a better place for questions of this nature, as is chat. I'm not exactly sure what you are trying to do, could you clarify more? What do you want to do with the #Def after retrieving it? Also make note, values and defs will be changing slightly in a release (the next?) @mpvl is working on this now and knows all about this. Not sure if docs are up anywhere, there are explanations about it and how things will work differently. |
I'm still learning cue (and of course cue is a still very much a moving target). I've read the recent release notes which explain the idea that you can think of definitions and values as two different namespaces (with definitions being prefixed with '#'). I guess based on that I was expecting to be able to lookup a definition as I can lookup a field, eg I'm afraid I can't remember the exact scenario where this need came up as it was a week or two ago. I've been working with kubernetes definitions (of which there are many!) and I think wanted to pluck out some of the definitions based on a list of strings. If I hit this again I'll report back... Ah yes I've been eagerly awaiting Github Discussions but hadn't noticed the cue repo already has them! I don't think I can hit a button to make this thread a discussion unfortunately but I'll certainly post there in the future and join in on chat more... |
Just noticed this latest commit by @mpvl that looks related 53d18cc albeit on the go side of the code rather than in cue. Also related is the idea of 'dynamic definitions' which I need to think more about and see if I'm using them or can get by without them. Just linking here for future reference (for myself and others)... Search 'dynamic definitions' here: |
One idea is that if people need indexable definitions, they could add an indirection, so in your case:
But that won't work if the definitions are a given. The question is what the use case is for dynamic definitions. The only way around having full dynamic lookup for definitions is in the form of a language change, for instance allowing The question is how much people really need this functionality. |
This issue has been migrated to cue-lang/cue#421. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Is your feature request related to a problem? Please describe.
Hi. How can I index into a struct to access a #Foo (a cue definition) and not ("Foo" or "#Foo" regular fields).
I also tried this and got the same "undefined field Foo" error:
I like the new idea from the latest release notes of thinking of #-prefixed things as a separate namespace (for definitions).
I just can't work out how to do the indexing above! Is this currently possible? (and if not, please consider it a feature request)
The text was updated successfully, but these errors were encountered: