You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would propose to extend the HOCON syntax to simplify declaration of an array of objects.
Currently it is possible to declare an array of primitive types or objects like the following:
[ 3, 6, 9 ]
[ alpha, beta, delta ]
[
{ a : 42, c : 5 }
{ b : 43, c : 6 }
]
But take in consideration the declaration of a list of assignments, for example: alpha = 1, beta = 2, delta = 3. Currently it is required the following definition:
[ { alpha = 1 } , { beta = 2 }, { delta = 3 } ]
It is much nicer if it would be possible to use the following syntax
[ alpha = 1, beta = 2, delta = 3 ]
The benefit is more evident for more complex declaration like this
It is an interesting idea. Would have to play with the parser and see if it's workable. It creates some ambiguity; note that outside of [], "a=1, b=2" is a single object, but here "a=1,b=1" would be two objects in a list. Also it requires the parser to "look ahead" because in all existing cases, if you see "alpha" in "alpha=1" you know that "alpha" is an object key already. But in this case, you don't know whether "alpha" is an object key or just a string, until you get to the "=" or ":" - so that's a look-ahead to the next token that is never (if I remember right) currently done. Anyway those are just some possible issues I thought of offhand, it would need more digging in.
I don't think that it will create an ambiguity, on the contrary in my opinion it would be even more coherent with the JSON array semantic. In fact an array can hold a list of primitive types or objects, so the assignment notation can only represent an object since it is not a primitive types.
My real use case it the following: I have a list of components, for each of them I have to provide a configuration. I know that I could use the object notation instead of the array, for example:
But the main problem with this approach is that I cannot have different configuration for the same "component" because the last will override the previous ones. So here, the array is the best choice:
I would propose to extend the HOCON syntax to simplify declaration of an array of objects.
Currently it is possible to declare an array of primitive types or objects like the following:
But take in consideration the declaration of a list of assignments, for example: alpha = 1, beta = 2, delta = 3. Currently it is required the following definition:
It is much nicer if it would be possible to use the following syntax
The benefit is more evident for more complex declaration like this
instead of
The underlying would not change but the syntax would be much more readable in the spirit of the project.
Thanks
The text was updated successfully, but these errors were encountered: