{"action":"created","issue":{"url":"https://api.github.com/repos/tomhrr/dale/issues/201","repository_url":"https://api.github.com/repos/tomhrr/dale","labels_url":"https://api.github.com/repos/tomhrr/dale/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/tomhrr/dale/issues/201/comments","events_url":"https://api.github.com/repos/tomhrr/dale/issues/201/events","html_url":"https://github.com/tomhrr/dale/issues/201","id":365860040,"node_id":"MDU6SXNzdWUzNjU4NjAwNDA=","number":201,"title":"Macro is evaluated for type information when not necessary","user":{"login":"ChengCat","id":33503784,"node_id":"MDQ6VXNlcjMzNTAzNzg0","avatar_url":"https://avatars1.githubusercontent.com/u/33503784?v=4","gravatar_id":"","url":"https://api.github.com/users/ChengCat","html_url":"https://github.com/ChengCat","followers_url":"https://api.github.com/users/ChengCat/followers","following_url":"https://api.github.com/users/ChengCat/following{/other_user}","gists_url":"https://api.github.com/users/ChengCat/gists{/gist_id}","starred_url":"https://api.github.com/users/ChengCat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChengCat/subscriptions","organizations_url":"https://api.github.com/users/ChengCat/orgs","repos_url":"https://api.github.com/users/ChengCat/repos","events_url":"https://api.github.com/users/ChengCat/events{/privacy}","received_events_url":"https://api.github.com/users/ChengCat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-02T11:47:38Z","updated_at":"2018-10-15T13:33:49Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```\r\n(import cstdio)\r\n(import macros)\r\n(import operator-macros)\r\n\r\n(using-namespace std.macros\r\n  (def m (macro intern (void)\r\n    (printf \"macro is evaluated\\n\")\r\n    (mnfv mc 1))))\r\n(def main (fn extern-c int (void)\r\n  (+ (m) (m) (m))\r\n  0))\r\n```\r\n\r\nMacro `m` is evaluated 6 times during compilation, while I expect `m` to be evaluated only 3 times. If I am not mistaken, in the context `+` is overloaded as follows:\r\n1. procedure taking 2 arguments of the same type;\r\n2. macro taking 3 or more arguments of any type"},"comment":{"url":"https://api.github.com/repos/tomhrr/dale/issues/comments/429854128","html_url":"https://github.com/tomhrr/dale/issues/201#issuecomment-429854128","issue_url":"https://api.github.com/repos/tomhrr/dale/issues/201","id":429854128,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTg1NDEyOA==","user":{"login":"porky11","id":11576385,"node_id":"MDQ6VXNlcjExNTc2Mzg1","avatar_url":"https://avatars1.githubusercontent.com/u/11576385?v=4","gravatar_id":"","url":"https://api.github.com/users/porky11","html_url":"https://github.com/porky11","followers_url":"https://api.github.com/users/porky11/followers","following_url":"https://api.github.com/users/porky11/following{/other_user}","gists_url":"https://api.github.com/users/porky11/gists{/gist_id}","starred_url":"https://api.github.com/users/porky11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/porky11/subscriptions","organizations_url":"https://api.github.com/users/porky11/orgs","repos_url":"https://api.github.com/users/porky11/repos","events_url":"https://api.github.com/users/porky11/events{/privacy}","received_events_url":"https://api.github.com/users/porky11/received_events","type":"User","site_admin":false},"created_at":"2018-10-15T13:33:49Z","updated_at":"2018-10-15T13:33:49Z","author_association":"CONTRIBUTOR","body":"One of the problems of the typed macros also is following:\r\nYou don't even need to use the form, that returns one type.\r\nSo passing the evaluated macro in such a case really seems reasonable.\r\n\r\nDispatching on argument length before type dispatch also seems like a good idea.\r\n\r\n* Only one form?\r\n    -> Function?\r\n\r\n* Typed versions exist for argument length?\r\n    Evaluate all forms, pass expanded forms to macro or function, where types are required\r\n* Only one untyped macro exists for argument length?\r\n    Don't try to evaluate any argument at all (probably better, when you have to specify not to typecheck at all (`(attr notype)`))\r\n\r\nThis way, the only way to evaluate a macro, which is a macro argument, multiple times is by not specifying the argument type for one field, but still just evaluate it in the macro itself.\r\nSo all arguments get evaluated once, but when you don't specify the arguments to be typed, you get the unexpanded version of that macro.\r\nThe untyped versions are intended as arguments, which should be transformed before expanding them.\r\n\r\n\r\n"}}
{"actor":{"display_login":"porky11"}}