in reply to Doubley surprised by fat commas

Being Perl there's lots of documentation. I spent some time trawling through said documentation without finding anything to suggest this was expected behavior for a function call list before posting my question. I intended to mention that in my OP, but a meeting intervened and I did a hasty finish and post.

I'm afraid "That's what Perl does" answers don't really advance the needle on the understanding gauge, so I did some more digging. The key is in perldata in the List value constructors section:

LISTs do automatic interpolation of sublists. ... The null list is represented by (). Interpolating it in a list has no effect. Thus ((),(),()) is equivalent to (). ... lists may end with an optional comma to mean that multiple commas within lists are legal syntax. The list 1,,3 is a concatenation of two lists, 1, and 3, the first of which ends with that optional comma. 1,,3 is (1,),(3) is 1,3

So, there we are. It is intended and documented behavior, and I've learned something. Turns out the information is in the data, not the operator.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Doubley surprised by fat commas
by parv (Vicar) on Jun 10, 2021 at 02:58 UTC

    Thanks for finding "perldata". There should have been references to it in "perlsyn" & "perlop".

A reply falls below the community's threshold of quality. You may see it by logging in.