Quantcast
ESOUI - View Single Post - Updating stuff on the Wiki
View Single Post
04/13/14, 06:57 AM   #14
Cr4x
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by Iyanga View Post
myfunc(object, param1, param2)

That's the signature.

That LUA allows myfunc to be called in three ways, as:
obj.myfunc(otherobj, param1, param2)
obj.myfunc(obj, param1, param2)
obj:myfunc(param1, param2)

does not suddenly change the signature of myfunc.
I would say, it depends how it is declared.
because you should always document the declaration and not the "calls"

Originally Posted by Iyanga View Post
The signature for string.len is string.len(string s).
It is not string.len(), just because you can use name:len() as shorthand for name.len(name). And I have never seen a documentation that pretends that string.len(string s) would be string.len(). And LUA documentation is obviously even older than WoW addon documentation.
http://lua-users.org/wiki/StringLibraryTutorial
Just an example

Originally Posted by Iyanga View Post
You can easily see the difference if you take the opposite example and make a function
myfunc(param1, param2)

Calling this function with obj:myfunc(param1, param2) will not work and you would never call this function with obj.myfunc(obj, param1, param2), because you see immediately that it violates the signature.
LOL sorry, but you are comparing apples with pears

So
Declaration: function MyObj.myfunc(self, param1,param2) end
Usage: MyObj.myfunc(MyObj, foo, bar)
or: MyObj:myfunc(foo,bar)

however >
Declaration: function MyObj:myfunc(param1, param2) end
Usage: MyObj.myfunc(MyObj, foo, bar)
or: MyObj:myfunc(foo,bar)

2 declarations using a different parameter list, but on the stack the functions are the same, 3 arguments, doesnt matter how they called.

In other languages you dont have to use such ":" operator, because a "this" reference to the object itselfs exists.
  Reply With Quote