-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
variable fieldnames do not seem to have a context #217
Comments
In the case of
The design actually does manifest in the spec in a few ways:
However I would say that this definitely needs to be more prominently described in the tutorial because it does affect programmers and otherwise it's not really visible except to language nerds. It is also the case that you are not inside the object in |
In case_studies/micromanage/lib/mmlib/v0.1.2/service/amazon.libsonnet:256 the local var service is used, which is defined further out and is therefore OK. The line is commented out, but looks like it should work. |
In static_analysis.cpp
What is happening there is the in_object status is preserved from outside the braces in the case of field names, but overridden to |
Interesting! Ok, yes, that makes sense; it is reasonable, though non-intuitive, and I think that it probably misses some important use cases. I think there are two ways to make this semantically meaningful. Either:
I think, as it turns out, both of these would result in the same evaluation for the three examples you suggested before -- But, irritatingly, I think they would result in the wrong answer for the test that I gave in my original issue! I'm not sure what the interplay here would be with overriding fields, or what phase that's implemented at. |
Yeah I think the issue is fundamental and any paradox-free design would have more edge cases than the current design. I think you can do what you want like this though?
This static binding of id means you cannot override it later of course, but if you don't need that it should be fine. |
Ok, I spent a bunch of this afternoon converting stuff to that style. It's tough to reduce what I'm trying to do too much without just giving you the entire source; in practice, what doing that forces me to do is to now pass around a 'params' object as a parameter, and do my inheritance like that. It's not the end of the world, but it is a little less clean. I'm not sure that the other solutions would have more edge cases, but certainly they would have different edge cases -- trading off some unintuitive behavior in the early stage to unintuitive behavior later on. Either way, thanks for the workaround. |
If you can share some code that is close to the concrete thing you're doing I would definitely be interested in seeing it. You can obfuscate all the primitive values and field names, because really it is the differences and similarities between different parts of the JSON output that matter (and the kinds of modifications one routinely wants to make to them). The absolute values don't matter at all. |
I'll try and alpha-vary it either this weekend or next week at work. |
I tried to use a variable field name as part of a mixin, and it seems that field names don't seem to be evaluated in the scope of the object they came from. If I try using
self
, I get the error "Can't use self outside of an object", and if I try using the standard technique to bind it with alocal
, I get the local as an "Unknown variable".Additionally, semantics for fieldnames of pattern
'[' e ']'
don't appear to be specified in the spec.Here's an example of what I'm trying to accomplish:
Looking at core/static_analysis.cpp:130 or so, it looks like the right thing should be happening, but I don't understand enough as to why the wrong
vars
are showing up there. (I'm not sure if my employer has a CLA signed, so I don't want to go digging too deeply, since I can't produce a patch anyway 😄.)Looks like this might also have been tripped on in case_studies/micromanage/lib/mmlib/v0.1.2/service/amazon.libsonnet:256 or so?
The text was updated successfully, but these errors were encountered: