{"action":"created","issue":{"url":"https://api.github.com/repos/hylang/hy/issues/891","labels_url":"https://api.github.com/repos/hylang/hy/issues/891/labels{/name}","comments_url":"https://api.github.com/repos/hylang/hy/issues/891/comments","events_url":"https://api.github.com/repos/hylang/hy/issues/891/events","html_url":"https://github.com/hylang/hy/issues/891","id":100449002,"number":891,"title":"apply not good enough to replace Python's unpacking","user":{"login":"gilch","id":3346292,"avatar_url":"https://avatars.githubusercontent.com/u/3346292?v=3","gravatar_id":"","url":"https://api.github.com/users/gilch","html_url":"https://github.com/gilch","followers_url":"https://api.github.com/users/gilch/followers","following_url":"https://api.github.com/users/gilch/following{/other_user}","gists_url":"https://api.github.com/users/gilch/gists{/gist_id}","starred_url":"https://api.github.com/users/gilch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilch/subscriptions","organizations_url":"https://api.github.com/users/gilch/orgs","repos_url":"https://api.github.com/users/gilch/repos","events_url":"https://api.github.com/users/gilch/events{/privacy}","received_events_url":"https://api.github.com/users/gilch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/hylang/hy/milestones/8","html_url":"https://github.com/hylang/hy/milestones/Grand%20Language%20Cleanup","labels_url":"https://api.github.com/repos/hylang/hy/milestones/8/labels","id":1224085,"number":8,"title":"Grand Language Cleanup","description":"There are a couple of workarounds in the language that have bugs and issues that are hard (or even impossible) to solve, because of being tied to Python semantics. Instead of trying to be something the language isn't, these should be cleaned up, and replaced with something more pythonic - and thus less buggy from a pythonist PoV. To ease migration, a compatibility shim may be provided.\r\n\r\nLets track these here!","creator":{"login":"algernon","id":17243,"avatar_url":"https://avatars.githubusercontent.com/u/17243?v=3","gravatar_id":"","url":"https://api.github.com/users/algernon","html_url":"https://github.com/algernon","followers_url":"https://api.github.com/users/algernon/followers","following_url":"https://api.github.com/users/algernon/following{/other_user}","gists_url":"https://api.github.com/users/algernon/gists{/gist_id}","starred_url":"https://api.github.com/users/algernon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algernon/subscriptions","organizations_url":"https://api.github.com/users/algernon/orgs","repos_url":"https://api.github.com/users/algernon/repos","events_url":"https://api.github.com/users/algernon/events{/privacy}","received_events_url":"https://api.github.com/users/algernon/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":14,"state":"open","created_at":"2015-07-24T13:55:39Z","updated_at":"2015-08-12T09:40:25Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-08-12T01:53:40Z","updated_at":"2015-08-12T15:16:17Z","closed_at":null,"body":"In both Common Lisp and Python, I know that I can apply some parameters and then unpack the rest from a list.\r\n\r\nPython.\r\n```Python\r\n>>> def foo(*args):\r\n\tprint(args)\r\n\r\n\t\r\n>>> foo(1,2,3,*[4,5,6])\r\n(1, 2, 3, 4, 5, 6)\r\n```\r\nHere's a similar example in Common Lisp.\r\n```Lisp\r\n* (defvar foo (lambda (&rest args) (print args)))\r\n\r\nFOO\r\n* (apply foo 1 2 3 '(4 5 6))\r\n\r\n(1 2 3 4 5 6)\r\n(1 2 3 4 5 6)\r\n```\r\nLet's try that in Hy\r\n```Hy\r\n=> (defn foo [&rest args] (print args))\r\n=> (apply foo 1 2 3 [4 5 6])\r\n  File \"<input>\", line 1, column 1\r\n\r\n  (apply foo 1 2 3 [4 5 6])\r\n  ^-----------------------^\r\nHyTypeError: `apply' needs at most 3 arguments, got 5\r\n\r\n=>\r\n```\r\nHmnope. Hy's apply won't accept arguments before the list. Can we get a fix for this please?"},"comment":{"url":"https://api.github.com/repos/hylang/hy/issues/comments/130339252","html_url":"https://github.com/hylang/hy/issues/891#issuecomment-130339252","issue_url":"https://api.github.com/repos/hylang/hy/issues/891","id":130339252,"user":{"login":"gilch","id":3346292,"avatar_url":"https://avatars.githubusercontent.com/u/3346292?v=3","gravatar_id":"","url":"https://api.github.com/users/gilch","html_url":"https://github.com/gilch","followers_url":"https://api.github.com/users/gilch/followers","following_url":"https://api.github.com/users/gilch/following{/other_user}","gists_url":"https://api.github.com/users/gilch/gists{/gist_id}","starred_url":"https://api.github.com/users/gilch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilch/subscriptions","organizations_url":"https://api.github.com/users/gilch/orgs","repos_url":"https://api.github.com/users/gilch/repos","events_url":"https://api.github.com/users/gilch/events{/privacy}","received_events_url":"https://api.github.com/users/gilch/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T15:16:17Z","updated_at":"2015-08-12T15:16:17Z","body":">Short of adding vectors around args and kwargs\r\n\r\nSomething like this?\r\n```Hy\r\n(apply foo 1 2 3 [(, 4 5 6) {\"k\" \"v\"}])\r\n```\r\nYou'd still need an empty args if you only wanted to unpack kwargs. \r\n```Hy\r\n(apply foo 1 2 3 [(,) {\"k\" \"v\"}])\r\n```\r\nThis doesn't seem any better than option two.\r\n\r\n>  I don't know how to do this in a clean and predictable way.\r\nOption three might be a little confusing, but the other two are very predictable.\r\n\r\n> And if + isn't good enough when you mix types, try itertools.chain.\r\n\r\n`chain` does work. Still kind of a pain to need it and to import it."}}