3 ms·
There are also languages like Nim which have a method call syntax, that means: myMethod(myObj, myParams) == myObj.myMethod(myParams)
by davidkunz 6y ago
There are also languages like Nim which have a method call syntax, that means:
myMethod(myObj, myParams) == myObj.myMethod(myParams)
- yellowapple 6y agoRelevantly, the same thing applies in Python, which is probably where Nim got it (though I don't recall if Python actually lets you interchange them - only that the thing on the left side of the dot is the first argument of the method). Perl also does this (but with -> rather than .), and also allows interchanging the syntax.
- nybble41 6y agoLua is another one. The following expressions are all equivalent: object:method(arguments...) object.method(object, arguments...) object["method"](object, arguments...) Lua objects are tables (associative arrays), the dot and colon operators are forms of table lookup, and methods are ordinary functions stored in the table (or more commonly its associated meta-table) which happen to take the object as their first argument. The colon operator, which can only be used as part of a function call, passes its left-hand operand to the function along with the other arguments.
- skocznymroczny 6y agoD also has this feature. Uniform Function Call Syntax.