3 ms·
There's no reason you couldn't type `noun.` and get autocomplete to `verb(noun)`
by jkcxn 7y ago
There's no reason you couldn't type `noun.` and get autocomplete to `verb(noun)`
- nlawalker 7y agoOr just support calling "verb(noun)" as "noun.verb()" all the way through: https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax
- unholiness 7y agoAt Onshape we're considering doing this for our language FeatureScript[0], as discussed here[1] This would make the call e.g. v1->cross(v2) syntactic sugar for the call cross(v1, v2). The main reason it's not just an obvious win for autocomplete and readability is that it provides for multiple ways to do one thing, and is one more thing you need to know when learning this new language. Rather than having some code call plane->yAxis() and other code call yAxis(plane), it might be nicer to have only one way. The other counterargument: the OOP-like syntax could support the expectation that polymorphism works like e.g. Java, where e.g. v1.cross(v2) would only considers the type of v1 when deciding which overload to call. FeatureScript has multiple dispatch and will consider the types of all arguments when choosing an overload. All that said, the change it seems like a win overall, but we're waiting for the language to mature more to see if clearer arguments emerge. [0] https://cad.onshape.com/FsDoc/ https://cad.onshape.com/FsDoc/ [1] https://forum.onshape.com/discussion/comment/33495/#Comment_33495 https://forum.onshape.com/discussion/comment/33495/#Comment_...
- nlawalker 7y ago> Rather than having some code call plane->yAxis() and other code call yAxis(plane), it might be nicer to have only one way. One option is a linter/formatter that can warn and configurably push you in one way or the other.