3 ms·
> Though I don't like the extra step Nim takes of dropping parentheses for 0 argument functions That isn't true, you need parentheses for procs with no argumen
by planetis 4y ago
> Though I don't like the extra step Nim takes of dropping parentheses for 0 argument functions
That isn't true, you need parentheses for procs with no arguments, else it's interpreted as a proc pointer. Try `echo` vs `echo()`.
> I can't think of any good reason why anyone would deliberately have two different functions with the same name in different cases anyway
It's used for declaring variables of an object. `type Foo = object` and `var foo: Foo`.
I like Nim's rules for identifiers, it prevents you for mistakenly declaring two different variables/procedures with similar names.
Other examples where, how you would write something doesn't matter, is Windows filesystems and gmail, reserving every possible derivative with a dot like your.name@gmail.com and y.ourname@gmail.com.
So it's not uncommon or weird. Just programming languages are overly restrictive.
- jdrek1 4y ago> That isn't true, you need parentheses for procs with no arguments, else it's interpreted as a proc pointer. Try `echo` vs `echo()`. My bad, I meant 0 argument member functions (or rather 0 additional argument functions, apart from the this pointer). So `foo: Foo` and then `i = foo.len()` directly shows me that I'm calling a function, `i = foo.len` looks like I just access a member variable. len is obviously not the best example but I still don't think hiding the fact that a function is being called is a good idea at all. > It's used for declaring variables of an object. `type Foo = object` and `var foo: Foo`. Good point, I didn't consider that. So far never came up in my code but I can see that it sometimes can be useful to do something like that. > So it's not uncommon or weird. Just programming languages are overly restrictive. Natural languages have been case sensitive long before programming languages existed. Again, I'm not saying it's a bad feature - on the contrary, definitely appealing in some case - it's just not what we're used to and hence a bit "weird".