13 ms·
Looking at the description, what I can't understand is why they adopted the weird (param_name label) construct for named parameters. IIRC the same is Objective-
by troupo 3y ago
Looking at the description, what I can't understand is why they adopted the weird (param_name label) construct for named parameters. IIRC the same is Objective-C and Swift.
- IshKebab 3y agoMy guess is that normally parameter names are not part of the API, so they added an explicit API name. I think it's a bit silly though. I would have gone for explicitly making keyword parameters.
- Joker_vD 3y agoInternal/external names distinction. It's always ugly.
- troupo 3y agoYeah, I can't understand the need for it :)
- halostatue 3y agoIt allows you to specify reserved words as parameter names which you would otherwise be unable to use. Ruby has this problem with keyword parameters and you need to use `binding.local_variable_get(:NAME)` to get such a reserved word.
- troupo 3y agoThere are not that many reserved words, and you can always use a different word ;)
- halostatue 3y agoSometimes a different word is the wrong word.
- lf-non 3y agoOh I wish more languages adopted this. It is nice to be able to name the externally visible parameters such that the invocation is natural to read (eg. DB.select(~from: userTable)), but it is better to have more explicit names on the implementation side (eg. tableName)
- troupo 3y agoHonestly, I don't see the reason, or the need, and I've used a dozen or more languages at this point.