{"action":"created","issue":{"url":"https://api.github.com/repos/gaborcsardi/argufy/issues/19","labels_url":"https://api.github.com/repos/gaborcsardi/argufy/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/gaborcsardi/argufy/issues/19/comments","events_url":"https://api.github.com/repos/gaborcsardi/argufy/issues/19/events","html_url":"https://github.com/gaborcsardi/argufy/issues/19","id":108935560,"number":19,"title":"Extend syntax to check return types as well","user":{"login":"jimhester","id":205275,"avatar_url":"https://avatars.githubusercontent.com/u/205275?v=3","gravatar_id":"","url":"https://api.github.com/users/jimhester","html_url":"https://github.com/jimhester","followers_url":"https://api.github.com/users/jimhester/followers","following_url":"https://api.github.com/users/jimhester/following{/other_user}","gists_url":"https://api.github.com/users/jimhester/gists{/gist_id}","starred_url":"https://api.github.com/users/jimhester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimhester/subscriptions","organizations_url":"https://api.github.com/users/jimhester/orgs","repos_url":"https://api.github.com/users/jimhester/repos","events_url":"https://api.github.com/users/jimhester/events{/privacy}","received_events_url":"https://api.github.com/users/jimhester/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-29T18:53:12Z","updated_at":"2015-09-29T21:52:36Z","closed_at":null,"body":"Not exactly sure of the format, perhaps just extending to replace any call of `?` with the checking code would work.  I can't really think of a time where `?` is used _within_ a function, so I don't think it would conflict with any existing code.\r\n\r\n```r\r\nfun <- function(x) (if (isTRUE(x)) 1 else \"1\") ? is.character\r\n\r\nfun(TRUE)\r\n# Error: is.character((if (isTRUE(x)) 1 else \"1\"))) is not TRUE\r\n```"},"comment":{"url":"https://api.github.com/repos/gaborcsardi/argufy/issues/comments/144201799","html_url":"https://github.com/gaborcsardi/argufy/issues/19#issuecomment-144201799","issue_url":"https://api.github.com/repos/gaborcsardi/argufy/issues/19","id":144201799,"user":{"login":"jimhester","id":205275,"avatar_url":"https://avatars.githubusercontent.com/u/205275?v=3","gravatar_id":"","url":"https://api.github.com/users/jimhester","html_url":"https://github.com/jimhester","followers_url":"https://api.github.com/users/jimhester/followers","following_url":"https://api.github.com/users/jimhester/following{/other_user}","gists_url":"https://api.github.com/users/jimhester/gists{/gist_id}","starred_url":"https://api.github.com/users/jimhester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimhester/subscriptions","organizations_url":"https://api.github.com/users/jimhester/orgs","repos_url":"https://api.github.com/users/jimhester/repos","events_url":"https://api.github.com/users/jimhester/events{/privacy}","received_events_url":"https://api.github.com/users/jimhester/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T21:52:36Z","updated_at":"2015-09-29T21:52:36Z","body":"Possible syntax ideas\r\n\r\n```r\r\n# this does not parse\r\nf <- function(x) ? is.numeric { 1 }\r\n#> Error: unexpected '{' in \"f <- function(x) ? is.numeric {\"\r\n\r\n# This does though\r\nf <- function(x) ? is.numeric ? { 1 }\r\n\r\n# Also this does\r\nf <- function(x) { 1 } ? is.numeric\r\n\r\n# But that might be weird for 1 expression functions?\r\nf <- function(x) 1 ? is.numeric\r\n```\r\n\r\nI think some meta-programming would work well for this. Search through the AST and replace any `return()` calls with the checking code followed by the return.  Then replace the last call in the function with the checking code (unless it is an explicit return and has already been done).\r\n\r\nI may try an implementation tomorrow if I can get some time."}}