Hacker News new | ask | show | jobs
by chromatic 4165 days ago
Except maybe that's actually a thing in perl, to use this behaviour as a feature, I don't know.

Yes, that's common. List processing via variadic arity functions is an explicit feature of Perl.

1 comments

Not explicit enough. Perl is the only language I've ever seen where

  sub f { return 1, 2 }
  my %x = (a => f(), b => f());
produces a three-element hash that has '2' as a key and 'b' as a value with no warnings. "Even offsets are keys" is far more error-prone than an actual syntax for hash literals, and splicing a list (not a hash!) into a hash doesn't need syntax this terse because it's hardly ever what I wanted. I think even PHP is more sane here.
I think even PHP is more sane here.

I'm not sure how an appeal to PHP as lowest-common-denominator of language sanity argues against understanding the return values of functions you call.

> understanding the return values of functions you call

Sure you should. But confusion between keys and values isn't useful, so there's no reason for a subexpression to be able to do that, and in PHP it can't.