Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Bug with lists?

by merlyn (Sage)
on Feb 18, 2002 at 13:48 UTC ( #146147=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Bug with lists?
in thread Bug with lists?

empty agreed, so it should be undef no?
I think this is where you are taking a leap of faith, and leaping in the wrong direction. {grin}

In fact, Perl hints the contrary in perldoc perldata:

You may have an optional comma before the closing parenthesis of a list literal, so that you can say: @foo = ( 1, 2, 3, );
So there, you're not getting 1,2,3,undef. Just 1,2,3. An extra embedded syntax-only comma was formerly illegal (I believe). I'm a bit surprised to see that it's now being nicely ignored, just as the trailing comma had been, but it's not totally inconsistent with the trailing-comma-ignored feature.

Conclusion: no bug, although not precisely documented to work with embedded comma as well as trailing comma.

-- Randal L. Schwartz, Perl hacker


Comment on Re: Re: Re: Bug with lists?
Download Code
Re: Re: Re: Re: Bug with lists?
by demerphq (Chancellor) on Feb 18, 2002 at 14:02 UTC
    Thanks merlyn, this seems like a credible explanation. Although as I said in the CB it seems like a bad call (contrary to DWIM, as well as the behaviour of about every other language.)

    Nevertheless I would like to post this to perl5porters, if only to get the documentation improved. That would be the correct forum wouldn't it?

    Yves / DeMerphq
    --
    When to use Prototypes?

      This has been posted to p5p in the past. See here. FWIW I was said user, and that was less than 6 months after I started learning Perl.

      IMHO the best possible documentation is to firmly get down Perl's idea of what a list is versus what a scalar is. If you understand what a list is, then it is obvious that ,, shouldn't insert an undef. If you don't, particularly if you are translating some VB code that uses commas as placeholders...

        Well, its nice to know im in good company. /ducks ;-)

        Its true what you say about list context. And to be honest prior to this I would have said that I _did_ grok it. But it appears I am wrong. The fact that this wasn't docmented under perlop (which as Ive been harping about is where I would have expected this behaviour to be documented) is what threw me.

        Anyway, this is a lesson that won't be forgotten any time soon, if at all. :-)

        Yves / DeMerphq
        --
        When to use Prototypes?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-08-30 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls