{"action":"created","issue":{"url":"https://api.github.com/repos/wiremod/wire/issues/926","labels_url":"https://api.github.com/repos/wiremod/wire/issues/926/labels{/name}","comments_url":"https://api.github.com/repos/wiremod/wire/issues/926/comments","events_url":"https://api.github.com/repos/wiremod/wire/issues/926/events","html_url":"https://github.com/wiremod/wire/issues/926","id":95979003,"number":926,"title":"E2: Add function type. For use in searching and calling functions.","user":{"login":"Measuring","id":1107063,"avatar_url":"https://avatars.githubusercontent.com/u/1107063?v=3","gravatar_id":"","url":"https://api.github.com/users/Measuring","html_url":"https://github.com/Measuring","followers_url":"https://api.github.com/users/Measuring/followers","following_url":"https://api.github.com/users/Measuring/following{/other_user}","gists_url":"https://api.github.com/users/Measuring/gists{/gist_id}","starred_url":"https://api.github.com/users/Measuring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Measuring/subscriptions","organizations_url":"https://api.github.com/users/Measuring/orgs","repos_url":"https://api.github.com/users/Measuring/repos","events_url":"https://api.github.com/users/Measuring/events{/privacy}","received_events_url":"https://api.github.com/users/Measuring/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":33,"created_at":"2015-07-20T03:38:31Z","updated_at":"2015-07-27T23:09:30Z","closed_at":null,"body":"**Edit after discussion (renamed title):**\r\nI've changed the title to represent what seems to be the way to go: Creating a delegate type for looking up functions in E2 and calling them afterwards. For backwards compatibility, strfuncs need to stay.\r\n\r\n*Features required for approval (so far)*\r\n- Function type\r\n- - Points to any one function or nothing (nofunction(), like noentity()).\r\n- - Can be retrieved at runtime through getFunction(name, [args]).\r\n- - Can be called using \"getFunction(\"name\", Args):call(Args)\".\r\n- - Possibly: Can get name, return type, extension type and parameters from (as array of types in order).\r\n\r\nIf features should be different. Would like to hear so.\r\n\r\n**Original post:**\r\nThe main reason for this feature is that you cannot safely check if a function can be called or not. Not sure if the E2 can easily implement eval(). Otherwise maybe something like a try-catch when E2 throws an error. So that you can handle it and continue. Without respawning the E2.\r\n\r\nSyntax propose:\r\n```lua\r\nif (first()) {\r\n    function entity:sayPM(Message:string) {\r\n        concmd(\"say /pm \" + This:name() + \" \" + Message)\r\n    }\r\n}\r\n\r\n......\r\n......\r\n......\r\n\r\nif (chatClk(owner()) {\r\n    Targets = findPlayersByName(...)\r\n\r\n    local Command = lastSaid(owner())\r\n    eval(Command)\r\n    # Possibly:\r\n    # local Players = evalArray(\"players()\")\r\n    # local OwnerName = evalString(\"owner():name()\")\r\n    if (!lastEval()) {\r\n        # Fallback plan.\r\n    }\r\n}\r\n```\r\n\r\nExample chat: \"# sayPM(Targets, \"I'm your dynamic calling\")\"\r\n\r\nHaving this feature will allow users to create command-like utilities without getting an error message when calling an undefined function with \"str\"()."},"comment":{"url":"https://api.github.com/repos/wiremod/wire/issues/comments/125375446","html_url":"https://github.com/wiremod/wire/issues/926#issuecomment-125375446","issue_url":"https://api.github.com/repos/wiremod/wire/issues/926","id":125375446,"user":{"login":"Measuring","id":1107063,"avatar_url":"https://avatars.githubusercontent.com/u/1107063?v=3","gravatar_id":"","url":"https://api.github.com/users/Measuring","html_url":"https://github.com/Measuring","followers_url":"https://api.github.com/users/Measuring/followers","following_url":"https://api.github.com/users/Measuring/following{/other_user}","gists_url":"https://api.github.com/users/Measuring/gists{/gist_id}","starred_url":"https://api.github.com/users/Measuring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Measuring/subscriptions","organizations_url":"https://api.github.com/users/Measuring/orgs","repos_url":"https://api.github.com/users/Measuring/repos","events_url":"https://api.github.com/users/Measuring/events{/privacy}","received_events_url":"https://api.github.com/users/Measuring/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T23:09:30Z","updated_at":"2015-07-27T23:09:30Z","body":"@TomyLobo Well, a function pointer is really basic. So I thought that delegates would make it more extensible. Like this answer: http://stackoverflow.com/a/8097290/1277156 \"function objects\".  Containing information about the function. Like arguments, return type. Instead of only being able to call it."}}