let people = [
Person(name: "John", age: 45),
Person(name: "Kate", age: 30)
]
Verbosity at its finest. Compare with C++: Person people[] {
{ “John”, 45 },
{ “Kate”, 30 }
}; let people = [
Person(name: "John", age: 45),
Person(name: "Kate", age: 30)
]
Verbosity at its finest. Compare with C++: Person people[] {
{ “John”, 45 },
{ “Kate”, 30 }
};BOA is more compact, but it's possible to get the arguments wrong, and the type system won't save you if you exchange two arguments of the same type.
There is no reminder anywhere that 45 and 30 are ages.
That's also true in function calls that do not use keyword arguments (the vastly prevalent paradigm in mainstream languages), but function calls specify a function name which can reveal something, like set_age(john, 45).
Some languages have both.
No knowing anything about Nim, I have no reason to believe that it has no way to achieve a compact way for initializing an array or list of objects using just positional arguments, and no repetition of the type name. If nothing else, surely there has to be a way to write an array of tuples, and that aggregate can surely be passed to some function that iterates over it and constructs the implied Person objects.
On the C++ front, I seem to recall C++ recently adding C99 designated initializers or planning to. If so, then { .name = "John", .age = 45 } will be possible, and C++ coders will end up using it.
For example, just like initialization lists on constructors, initialization order is relevant.
Maybe if you'd used auto (if that's possible - now I understand that auto is out of fashion due to sometimes forcing copies) it'd be closer.
`let people = [`
vs
`Person people[] {`
Just for starters...