Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Doubley surprised by fat commas

by GrandFather (Saint)
on Jun 09, 2021 at 23:57 UTC ( #11133711=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2021-10-22 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?