4 ms·
I'm not a fan of this: 'Hello world' replaceFromIndex: 0 toIndex: 4 with: 'Bye' At first sight you might think, oh great don't even need to read the documenta
by didibus 6y ago
I'm not a fan of this:
'Hello world' replaceFromIndex: 0 toIndex: 4 with: 'Bye'
At first sight you might think, oh great don't even need to read the documentation (which is the author argument in favour of this). But, is "toIndex" inclusive or exclusive? Don't know, so now I need to read the documentation anyways and just learn the behavior of the function. And once I did, all those names just become visual noise that my eyes need to skip over when reading and verbosity when writing.
Also, if you're going to go with this style, I'd much rather have function first (as FP should):
replace in: 'Hello world' fromIndex: 0 toIndex: 4 with: 'Bye'
Which brings me to my second point, I prefer languages that just allow both. Some functions are better positional and other named and some a mix of both. Let each function choose the most appropriate one. For example, are we really going to do this?
100 divide with: 5
or
divide theNumber: 100 with: 5
Ya, it reads like an explanation for a 5 year old, but as a professional programmer I'd much rather:
divide 100 5
My point being, certain functions are intuitive even with positional args and others arn't, only the latter should have named args.
Now for the intellisense section I agree, but I think you can solve it with IDE UX. Like just provide a command that lists all locals for you to pick and then lists all functions whose first argument is of that type. Or heck, have it that after you type a var name, it lists functions over it but the list shows to the left and when you pick it autocompletes the function text to the left of it.