In my experience in JS, this has a somewhat undesirable effect of having the names be more informative than they should/could.
Imagine I have something like this code here:
let
sizeOfForest = SquareKm 3
-- Loads of other properties
typeOfTree = Elm
in
Forest.create
{ size = sizeOfForest
, trees = Tree.build typeOfTree
-- otherProperties...
}
Now, with the availability of this syntax, people will (more) likely change the names of the variables to something more generic and less information, in order to be able to use this syntax.
let
size = SquareKm 3
-- Loads of other properties
typeOfTree = Elm
in
Forest.create
{ size
, trees = Tree.build typeOfTree
-- otherProperties...
}
I find that size is less informative now, especially if there are a lot of other names introduced in the same scope.
I’m not saying that this renaming always goes in the wrong direction. But I think that in general, the names will become less informative than before. (The names in my example are obviously debatable, as they generally are in most contexts)
I also agree with @dillonkearns that renaming things leads to more tedious work. If you rename the variable, then you need to replace {name} by {name = newName} everywhere, and if you rename the field name for the function/record, you will also need to add {newName = name} everywhere it was used (maybe also rename name in that context too, and so on).
Also, it then becomes quite annoying if you have several fields with the same name but that should not have the same value.
let
typeOfTree = Elm
sizeOfTrees = Meter 1
size = SquareKm 3 -- should be sizeOfForest to be clearer
trees =
Tree.build
{ size = sizeOfTrees
, typeOfTree
}
in
Forest.create
{ size
, trees
}
I imagine people (as I have myself) thinking “Oh no, I couldn’t apply the shortcut to size for Tree.build. How can I refactor this to be able to?”. And I don’t think that kind of refactor would necessarily be helpful.
I have enjoyed my time using this shortcut in JS, and I still use it when it makes sense, but I do feel like it pulls me towards less informative code. I have to actively resist in order to make my code more readable.