{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2438","id":108620781,"number":2438,"title":"Cartesian product is weird with zero elements","user":{"login":"alphapapa","id":601365,"avatar_url":"https://avatars.githubusercontent.com/u/601365?v=3","gravatar_id":"","url":"https://api.github.com/users/alphapapa","html_url":"https://github.com/alphapapa","followers_url":"https://api.github.com/users/alphapapa/followers","following_url":"https://api.github.com/users/alphapapa/following{/other_user}","gists_url":"https://api.github.com/users/alphapapa/gists{/gist_id}","starred_url":"https://api.github.com/users/alphapapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphapapa/subscriptions","organizations_url":"https://api.github.com/users/alphapapa/orgs","repos_url":"https://api.github.com/users/alphapapa/repos","events_url":"https://api.github.com/users/alphapapa/events{/privacy}","received_events_url":"https://api.github.com/users/alphapapa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/fish-shell/fish-shell/milestones/8","html_url":"https://github.com/fish-shell/fish-shell/milestones/fish-tank","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/milestones/8/labels","id":343670,"number":8,"title":"fish-tank","description":"Issues (typically enhancement requests) that are worth considering but there's no consensus on, or where the path forward is not clear.","creator":{"login":"ridiculousfish","id":920838,"avatar_url":"https://avatars.githubusercontent.com/u/920838?v=3","gravatar_id":"","url":"https://api.github.com/users/ridiculousfish","html_url":"https://github.com/ridiculousfish","followers_url":"https://api.github.com/users/ridiculousfish/followers","following_url":"https://api.github.com/users/ridiculousfish/following{/other_user}","gists_url":"https://api.github.com/users/ridiculousfish/gists{/gist_id}","starred_url":"https://api.github.com/users/ridiculousfish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridiculousfish/subscriptions","organizations_url":"https://api.github.com/users/ridiculousfish/orgs","repos_url":"https://api.github.com/users/ridiculousfish/repos","events_url":"https://api.github.com/users/ridiculousfish/events{/privacy}","received_events_url":"https://api.github.com/users/ridiculousfish/received_events","type":"User","site_admin":false},"open_issues":50,"closed_issues":23,"state":"open","created_at":"2013-05-28T21:04:35Z","updated_at":"2015-10-01T22:44:27Z","due_on":null,"closed_at":null},"comments":26,"created_at":"2015-09-28T09:31:49Z","updated_at":"2015-10-17T14:50:38Z","closed_at":null,"body":"```fish\r\n$ set foo fizz\r\n$ set bar buzz\r\n$ echo {$foo}{$bar}\r\nfizzbuzz\r\n```\r\nHowever:\r\n```fish\r\n$ set bar buzz\r\n$ echo {$foo}{$bar}\r\n$\r\n```\r\nAnd:\r\n```fish\r\n$ set foo \"\"\r\n$ set bar buzz\r\n$ echo {$foo}{$bar}\r\nbuzz\r\n```\r\nShouldn't the second example output `buzz`?"},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/148921393","html_url":"https://github.com/fish-shell/fish-shell/issues/2438#issuecomment-148921393","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438","id":148921393,"user":{"login":"Lucretiel","id":1823405,"avatar_url":"https://avatars.githubusercontent.com/u/1823405?v=3","gravatar_id":"","url":"https://api.github.com/users/Lucretiel","html_url":"https://github.com/Lucretiel","followers_url":"https://api.github.com/users/Lucretiel/followers","following_url":"https://api.github.com/users/Lucretiel/following{/other_user}","gists_url":"https://api.github.com/users/Lucretiel/gists{/gist_id}","starred_url":"https://api.github.com/users/Lucretiel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lucretiel/subscriptions","organizations_url":"https://api.github.com/users/Lucretiel/orgs","repos_url":"https://api.github.com/users/Lucretiel/repos","events_url":"https://api.github.com/users/Lucretiel/events{/privacy}","received_events_url":"https://api.github.com/users/Lucretiel/received_events","type":"User","site_admin":false},"created_at":"2015-10-17T14:50:38Z","updated_at":"2015-10-17T14:50:38Z","body":"Keep in mind the simplest case of cartesian product expansion:\r\n\r\n```fish\r\nfunction search_bins\r\n    set locals '/' '/usr' '/usr/local'\r\n    for dir in $locals/bin\r\n        ...\r\n    end\r\nend\r\n```\r\n\r\nThis is a feature I make very consistent use of. I don't really see a way that we can keep this usage without having arbitrary cartesian product expansion, including 0-element variables causeing 0-element cartesian products. If `locals` is empty, I'd expect that for loop to run 0 times. Having one behavior for adjacent variable-literal and another behavior for adjacent variable-variable seems like it'd be a bad and inconsistent behavior.\r\n\r\n> make two adjacent lists simply concatenate the same way two scalars do\r\n\r\nAgain- do you have an idea for how this would work? What would the behavior be?\r\n\r\n```fish\r\nset var1 1 2 3\r\nset var2 a b c\r\ncount $var1$var2  # Outputs either 1, 5, or 6 under concatenation.\r\n```\r\n\r\nDoes the count output 1, 5, or 6? None of the behaviors except the last one makes sense in the general case of arrays, and there's no reason you wouldn't just to `count $var1 $var2` for that case. The first one doesn't make sense because arrays don't generally become single element except when quoted, and I can't think of a single practical case where you would want to concat only the last element of the first list and the first element of the last list. I'd find a literal ban on `$var1$var2` preferable to the second behavior.\r\n\r\nConsider as well that the first and last behavior (the only ones I think are worth considering) already have easy ways to work under the current syntax:\r\n\r\n```fish\r\nset string_concat \"$var1$var2\"; count $string_concat  # outputs 1\r\nset list_concat $var1 $var2; count $list_concat # outputs 6\r\n```\r\n\r\nOr, to use your original example:\r\n\r\n```fish\r\nset bar buzz\r\necho \"$foo$bar\"  # outputs \"buzz\"\r\n```\r\n\r\nIn general, double-quoting things is the canonical fish way to take a variable, which is a list of 0 or more elements, and make it into a fixed single element. I think we should be very very wary of implicitly converting lists into space separated strings- implicit conversions of that kind are some of the major variable gotchas of bash and other scripting languages, and fish's very strong and consistent \"list of strings\" data model is one of cornerstones of its usefulness and power."}}