-
Notifications
You must be signed in to change notification settings - Fork 967
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
allow value-concatenating an object to each list element #24
Comments
for those interested, a solution: https://github.com/carrot-garden/carrot-conf/tree/master/carrot-conf-list |
Won't withFallBack work here just fine? |
yes, but you must tell withFallBack where to get it from; if you have a lot of lists, would it not make sense to have a convention with a list builder? convention rules:
|
I'd be surprised if it was more than 5 lines of code to create a method that does that for any ConfigMap. |
you are right; and this argument can be extended to include all of jdk :-) but actually it is more then 5 lines |
The way you can have a fallback for each list item right now is something like this:
In the spec this is "value concatenation" it might be nice to avoid the repetition of You can also do this in code of course; when you load that list, At some point this is supposed to be a (relatively) obvious declarative file, so I'm reluctant to start making it into a mini programming language... I believe right now that concatenating/merging lists and objects is an error:
Viktor suggested the object in that case could be interpreted as "merge with each list element." One issue here is what happens if you have multiple lists in multiple places for the key, like say you have in reference.conf:
Then in application.conf, someone wants to merge in the defaults to their list, how does that happen... you'd sort of need that
and application.conf:
but then that's getting a little tricky to explain to people. If I were expecting third parties to edit application.conf, I'd probably go with the withFallback in code just so it'd be nice and easy to use. |
wow, you have a lot of cool ideas, thanks for sharing; "value concatenation" is way too verbose; but this one is my favorite:
I hope you can accept it? |
In the case of multiple defaults just apply them all? |
If this is part of the existing "value concatenation" mechanism then multiples are already defined I guess. Value concatenation lets you have as many values as you want (a bunch of adjacent strings => one big concatenated string, a bunch of adjacent lists => one big concatenated list, a bunch of adjacent objects => one big merged object). One thing I just thought of, currently value concatenation is associative in the mathematical sense because concatenation and merging are both associative. So it doesn't matter if the concatenation "operator" (syntactic adjacency) is left or right associative. However in this list+object case, it gets a little confusing. Multiple objects just works with either associativity; This doesn't really give you a way to specify defaults in the sense that reference.conf specifies defaults. It just gives you a shorthand. Because the "concatenation" trick is a purely local transformation. If reference.conf happens to build its list with the Another thought, this might naturally generalize such that a list of strings followed by a string value-concats the string to each element, but it breaks with a list of lists followed by a list since that already means something... inconsistent. Another line of thought here would be to have some explicit "map" operator which would maybe be clearer, or maybe not, since I don't really know how that operator would be written (the word I don't know. I'm thinking we keep thinking about it and it's sort of a post-1.0 thing... |
wow! this reads like scala type system spec now :-) can we get a taste of some simple interpretation of
for v 0.6 ? just to let more people see it and possibly share their thoughts? |
Please feel free to take a stab at it! |
ok, here is my stab:
into
and process as before |
Do you have code + tests? |
yes |
for additional discussion see #31 |
this is a feature request
use case:
the way I understand current mechanisms of HOCON
https://github.com/typesafehub/config/blob/master/HOCON.md
this would make this definition very verbose;
how about new/proposed
object$builder
syntax:The text was updated successfully, but these errors were encountered: