Replies: 3 comments 4 replies
-
Hi @parasyte! The main advantage Gura has over other configuration languages is that it only allows a single way of doing things (a single type of booleans, a single start/end mark of an array, a single way of defining an object, etc). |
Beta Was this translation helpful? Give feedback.
-
That's a good question. I agree with the sentiment that newlines are a sort
of space management and that visually they are much better than commas.
How about allowing both single new lines or commas, but not both? What
would that look like? Just to think about it:
array : [ 1, 2, 3,]
or
array: [1
2
3]
But not :
array: [1,
2,
3,]
It would make it difficult to change from one format to the other though.
The following would break, considering every line a new object
singers: [
name: "Andrea"
surname: "Bocelli"
gender: "Opera"
name: "Jimi"
surname: "Hendrix"
gender: "Rock"
]
Or perhaps the issue is allowing objects in arrays to be defined being
prefixed by a key, such as:
singers: [
ab:
name: "Andrea"
surname: "Bocelli"
gender: "Opera"
jh:
name: "Jimi"
surname: "Hendrix"
gender: "Rock"
]
But this would make such keys mandatory, and would make it very difficult
to interop. I guess JSON's use of braces comes in handy here, but we'd like
to avoid those.
…On Fri, Jun 24, 2022 at 4:09 PM Jay Oster ***@***.***> wrote:
My follow up question then is should commas be required on object
key-value pairs for consistency with arrays?
Having commas in one context but not in others seems to go against the
“one way to do things” mantra.
—
Reply to this email directly, view it on GitHub
<#19 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMA6B57P2JOGMTILIIDH4LVQYBYBANCNFSM5ZYFANDA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I agree but I think that what Jay is pointing to is a valid issue; in JSON,
you have braces (show in bold) that clearly delimit when an object starts
and ends. While I'm certainly not advocating for braces, it is true that
arrays composed of objects look a bit weird.
{
"ar": [
* {*
"elem1": true,
"elem2": false
* }*
]
}
…On Fri, Jun 24, 2022 at 4:34 PM Genaro Camele ***@***.***> wrote:
Commas are a delimiter of the elements within an array. The following
example:
ar: [
elem1: true
elem2: false]
Will generate the JSON equivalent of:
{
"ar": [
{
"elem1": true,
"elem2": false
}
]
}
Whereas:
ar: [
elem1: true, # <-- Note this comma
elem2: false]
Would generate:
{
"ar": [
{
"elem1": true
},
{
"elem2": false
}
]
}
That's why in the example of the singers we use commas to delimit, that
way it is consistent with the separation of different objects with all data
types, even if the indentation between both elements already indicates that
they are different objects (it could be due to the user forgetting to
indent, commas solve this problem by forcing the user to delimit all
elements with commas).
You can play with the equivalences using our configuration language
translator <https://config-translator.netlify.app/> and try those
examples you were not clear about
—
Reply to this email directly, view it on GitHub
<#19 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMA6BYORLNPBIRBBY5S2EDVQYEVDANCNFSM5ZYFANDA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I was looking at the Gura schema sketch I have been planning to try for my app, and I noticed that the comma array separators don't seem to be necessary (from tokenization or syntactic point of view) in multiline arrays.
Arrays of primitives can simply use line breaks as the element separator. Arrays of objects can use two line breaks as the element separator. This latter suggestion is even mentioned in the spec to encourage improving legibility:
The comma could be removed from the second array in the example above while preserving intent. It must be included in the first array to parse correctly.
Going back to primitives, It looks better (IMHO) without commas:
Why would anyone want to remove commas?
Gura is already sensitive to whitespace. And as shown in the example with arrays of objects, more whitespace increases legibility. It seems like commas are only useful in single-line arrays, since line breaks perform the same function (e.g. for key-value pairs in objects). It seems to me that removing the need for commas in multiline arrays will make arrays and objects more syntactically similar to one another without introducing parser ambiguity in most cases.
Perhaps commas should be optional. When I need to write a long array of numbers, I tend to put multiple elements on each line to optimize vertical space. For instance:
I would not like to force removal of the trailing comma, especially for cases like this example.
As another bit of feedback, When I initially read the spec, the need for these commas stuck out as "unique" compared to the rest of the spec. This example particularly was surprising:
Only one line has a comma here. It is hard to spot at a glance. Unlike the blank line which really stands out. For this reason I believe that multiple line breaks should be the preferred separator for arrays of objects, without the comma.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions