-
Notifications
You must be signed in to change notification settings - Fork 736
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
Support separating array and object items with a comma instead of a newline #498
Comments
It's on our short-list to support comma-separated values for arrays and object, but our plan is to make them optional. This will allow for the above as well as single line arrays: Any concerns with commas being optional and users having the choice here? |
(also I'm going to co-opt and rename the issue if that's ok. I thought we already had an issue tracking this) |
Internally, we are going back and forth on:
It would be great to get feedback on which of the above options is most desirable. |
Personally I would opt for number 3. Whatever the choice, please no 2 ;-) |
I agree, 3 is the most logical options (at least for .net developer :D) |
A vote for number 3 with also allowing a trailing comma for cleaner source control updates in the future. Again mimicking what other general purpose languages allow.
|
Somehow I prefer the current option where commas are not needed when you use new lines but are needed when you use the array in one line. It will be also for me initially hard to get used to this but it looks cleaner. Second preference is commas and allow both one liner and multiple lines. |
I vote for 3, but please allow for trailing comma (great idea @OxHobbs ). Adding/removing commas after reordering lines in an array is a hassle. |
My thoughts:
|
if you want a single line array declaration without commas, the member types must be simple types (string, int, bool). If you want complex type members, use multi-line and commas. Though personally I don't like 2 different syntaxes for arrays. That just adds confusion, IMO. |
I'm with @anthony-c-martin on the "always commas" or "never commas" bullet, and I also don't think we must reintroduce commas in a single-line array declaration - there are a number of functional programming languages like Lisp and Racket that don't use commas in an array declaration. For me the following statements are equally readable (it's just a matter of getting use to it):
Personally I have no preference, but if we go with the "always commas" option, we would need to consider whether to make the trailing comma required or not. |
+1 on the sentiment of "always or never, but not both". Personally, I am a fan of commas because at that point it is a javascript object literal and there are tools for translating between JSON and javascript objects: https://json-to-js.com/. That would be convenient when converting template code or working directly with the Azure API (i.e. the new "View resource JSON" functionality in the Azure portal)
@shenglol, what is the reasoning behind requiring the trailing comma? |
+1 on "always or never" as well. @alex-frankel I think long-term we should have "Export/View as Bicep" blades in the portal which should help with your concern. If there are commas, then in my opinion the trailing comma should be optional. I think @shenglol just moved me to team "no comma" 🙂. (I didn't know that there are somewhat popular languages that don't have a separator between array items.) |
Having trailing commas is helpful in that it:
To revise what I said, maybe we should relax and make dangling commas optional because typing them can sometimes be annoying, but once we implement a code formatter for bicep, we can add an option to always let the formatter insert them (which is a common configurable thing in modern code formatters like Prettier and Black). |
I really like how clean the code looks without the commas. I'd much prefer commas to only be required when using a single line e.g. I think the comma at the end of new lines puts Bicep one step closer to looking like JSON, i.e. a step backwards |
As someone who does automation extensively, in ARM, Ansible, and Terraform, I'm going to ask you to consider that you use some format that uses a standard language/DDL. ARM is JSON, Bicep is JSON-ISH. I would love it if objects in Bicep were valid JSON objects and that would mean arrays being a JSON Arrays, I've been coding in bicep extensively for about 3 weeks, and I can see using some sort json to bicep converter. Even if its something simple like generating a list of valid regions, I'd prefer cutting and pasting this:
|
I'm currently watching the video from Ignite and my first response is: why not make it look more like YAML in general?? I don't get the need for curly braces as well.
Something along the lines:
Source of @alex-frankel demo : https://github.com/alex-frankel/ignite-spring-21/blob/6a8015d88d1d29a13617e2fa66b06ac206d8df01/main.bicep#L16-L25 |
Adding my opinion to the discussion : I'm with always or never plus no comma team:) Copy paste from json to bicep will not work as we use single quotes instead double quotes. Commas are redundant here IMHO. |
What if you add Some might complain that this would along This is the choice that Clojure made in their surface syntax - see https://github.com/edn-format/edn |
In a lot of languages array items are separated by a comma.
It feels weird to not use comma's for array items.
Current
Proposal
Allow the array items to be split using a comma as it feels more natural.
The text was updated successfully, but these errors were encountered: