{"action":"created","issue":{"url":"https://api.github.com/repos/VisionLabs/torch-opencv/issues/17","labels_url":"https://api.github.com/repos/VisionLabs/torch-opencv/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/VisionLabs/torch-opencv/issues/17/comments","events_url":"https://api.github.com/repos/VisionLabs/torch-opencv/issues/17/events","html_url":"https://github.com/VisionLabs/torch-opencv/issues/17","id":113176272,"number":17,"title":"Modify function interface style","user":{"login":"shrubb","id":9570420,"avatar_url":"https://avatars.githubusercontent.com/u/9570420?v=3","gravatar_id":"","url":"https://api.github.com/users/shrubb","html_url":"https://github.com/shrubb","followers_url":"https://api.github.com/users/shrubb/followers","following_url":"https://api.github.com/users/shrubb/following{/other_user}","gists_url":"https://api.github.com/users/shrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/shrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shrubb/subscriptions","organizations_url":"https://api.github.com/users/shrubb/orgs","repos_url":"https://api.github.com/users/shrubb/repos","events_url":"https://api.github.com/users/shrubb/events{/privacy}","received_events_url":"https://api.github.com/users/shrubb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"shrubb","id":9570420,"avatar_url":"https://avatars.githubusercontent.com/u/9570420?v=3","gravatar_id":"","url":"https://api.github.com/users/shrubb","html_url":"https://github.com/shrubb","followers_url":"https://api.github.com/users/shrubb/followers","following_url":"https://api.github.com/users/shrubb/following{/other_user}","gists_url":"https://api.github.com/users/shrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/shrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shrubb/subscriptions","organizations_url":"https://api.github.com/users/shrubb/orgs","repos_url":"https://api.github.com/users/shrubb/repos","events_url":"https://api.github.com/users/shrubb/events{/privacy}","received_events_url":"https://api.github.com/users/shrubb/received_events","type":"User","site_admin":false},"milestone":null,"comments":14,"created_at":"2015-10-24T18:33:42Z","updated_at":"2015-11-02T08:37:26Z","closed_at":null,"body":"Currently, we use this style:\r\n\r\n```lua\r\nfunction cv.GaussianBlur(t)\r\n    local src =        assert(t.src)\r\n    local dst =        t.dst\r\n    local ksize =      cv.Size(assert(t.ksize))\r\n    -- ....\r\n```\r\n\r\nYou may notice that it's not very pleasant to call all the functions this way, as you'll have to either memorize all the argument names or to consult OpenCV docs right along:\r\n\r\n```lua\r\ncv.GaussianBlur{\r\n    src = image, \r\n    dst = image, \r\n    ksize = {7,7}, \r\n    sigmaX = 1.5,\r\n    sigmaY = 1.5\r\n}\r\n\r\ncv.Canny{\r\n    image = image,\r\n    edges = edges,\r\n    threshold1 = 0,\r\n    threshold2 = 30,\r\n    apertureSize = 3\r\n}\r\ncv.demosaicing{_src=edges _dst=edges, code=2}\r\ncv.imshow{winname=\"an image\", image=edges}\r\ncv.waitKey{delay=30}\r\n```\r\n\r\nThat's why it may be a good idea to support positional arguments as well:\r\n\r\n```lua\r\nfunction cv.GaussianBlur(t)\r\n    local src =        assert(t[1] or t.src)\r\n    local dst =        t[2] or t.dst\r\n    local ksize =      cv.Size(assert(t[3] or t.ksize))\r\n    local sigmaX =     assert(t[4] or t.sigmaX)\r\n    local sigmaY =     t[5] or t.sigmaY or 0\r\n    local borderType = t[6] or t.borderType or cv.BORDER_DEFAULT\r\n\r\n    -- ...\r\nend\r\n```\r\n\r\nI suggest that we should use this style from now on. I'll write a script to modify all the previous code."},"comment":{"url":"https://api.github.com/repos/VisionLabs/torch-opencv/issues/comments/152952119","html_url":"https://github.com/VisionLabs/torch-opencv/issues/17#issuecomment-152952119","issue_url":"https://api.github.com/repos/VisionLabs/torch-opencv/issues/17","id":152952119,"user":{"login":"shrubb","id":9570420,"avatar_url":"https://avatars.githubusercontent.com/u/9570420?v=3","gravatar_id":"","url":"https://api.github.com/users/shrubb","html_url":"https://github.com/shrubb","followers_url":"https://api.github.com/users/shrubb/followers","following_url":"https://api.github.com/users/shrubb/following{/other_user}","gists_url":"https://api.github.com/users/shrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/shrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shrubb/subscriptions","organizations_url":"https://api.github.com/users/shrubb/orgs","repos_url":"https://api.github.com/users/shrubb/repos","events_url":"https://api.github.com/users/shrubb/events{/privacy}","received_events_url":"https://api.github.com/users/shrubb/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T08:37:26Z","updated_at":"2015-11-02T08:37:26Z","body":"Yes, @fmassa is definitely right. This is the way positional/named args are handled in C++, as I remember."}}