Dicts are important because they allow you to model things common in JS, and they compile to a straight forward JS object. Proposing a dedicated syntax for defining a DIct.t:
let myDict = dict{
"field1": "1",
"field2": "2",
"field3": "3"
}
This could parse to (which is the way you'd define it today, manually):
let myDict = Js.Dict.fromArray([
("field1", "1"),
("field2", "2"),
("field3", "3"),
])
And together with this #6538 it could compile to:
var myDict = {
field1: "1",
field2: "2",
field3: "3",
}
I believe this would enhance ergonomics around dicts in the same way that the dedicated list{} syntax does for lists.
Related to this is also the question of whether dict should be a built in type.
Thoughts?
Related reading:
Dicts are important because they allow you to model things common in JS, and they compile to a straight forward JS object. Proposing a dedicated syntax for defining a
DIct.t:This could parse to (which is the way you'd define it today, manually):
And together with this #6538 it could compile to:
I believe this would enhance ergonomics around dicts in the same way that the dedicated
list{}syntax does for lists.Related to this is also the question of whether dict should be a built in type.
Thoughts?
Related reading:
list{}uses, to things likeset{},map{}etc)