4 ms·
In general in Nim (see footnote for fine print), `obj.someFunc` == `obj.someFunc()` == `someFunc(obj)` [0]. It's not a method bound to an object, as in `obj.me
by jboy 11y ago
In general in Nim (see footnote for fine print), `obj.someFunc` == `obj.someFunc()` == `someFunc(obj)` [0]. It's not a method bound to an object, as in `obj.method` in Python. So whenever there is some `obj.` in front of the function name, that's an argument being passed to a function call.
[0] http://nim-lang.org/docs/manual.html#procedures-method-call-syntax http://nim-lang.org/docs/manual.html#procedures-method-call-...
You can pass functions as first-class values (which Nim calls "procedural types" [1]) by supplying the function name without any arguments or parentheses, eg, `someFunc` on its own.
[1] http://nim-lang.org/docs/manual.html#types-procedural-type http://nim-lang.org/docs/manual.html#types-procedural-type
The base case occurs when the function takes no parameters: In this case, `someFunc` is a procedural type; `someFunc()` is a function invocation.
Footnote for interested readers: closures [2]; setter properties [3]; multi-methods that use dynamic dispatch [4].
[2] http://nim-lang.org/docs/manual.html#procedures-closures http://nim-lang.org/docs/manual.html#procedures-closures , [3] http://nim-lang.org/docs/manual.html#procedures-properties http://nim-lang.org/docs/manual.html#procedures-properties , [4] http://nim-lang.org/docs/manual.html#multi-methods http://nim-lang.org/docs/manual.html#multi-methods