in reply to Bug with lists?

Why should "empty" be undef??

my @empty= (); my @list= ( 1, (), empty(), /(hi)/g, @list[@empty], 2 ); sub empty { return } print "(", join(",",@list), ")\n";
The above code prints (1,2).

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Bug with lists?
by demerphq (Chancellor) on Feb 18, 2002 at 14:42 UTC
    Fair point. But I still would argue that ,, being interpreted as ,(), should be documented.

    Yves / DeMerphq
    --
    When to use Prototypes?

      But I still would argue that ,, being interpreted as ,(), should be documented.
      Actually, those are not the same either.
      $a = (4, 3, ,); # sets $a to 3 $b = (4, 3, (),); # sets $b to undef
      Please stop treating a trailing comma or two consecutive commas as anything other than "this disappears like you never even wrote it". It's like making something out of how many newlines you put after a statement. It has no semantics. Get it?

      -- Randal L. Schwartz, Perl hacker

        It has no semantics. Get it?

        Got it! :-)

        It's like making something out of how many newlines you put after a statement

        And I suppose this highlights the conceptual block here. Its easy to see/understand that a bunch of whitespace has no semantic meaning. Its a lot harder to see that a bunch of comas in the middle of something has no meaning... Hence the reason I'd like to see this documented at least.

        Yves / DeMerphq
        --
        When to use Prototypes?

        $a = (4, 3, ,); # sets $a to 3 $b = (4, 3, (),); # sets $b to undef
        Agreed, but that's a different issue. Here it is in scalar context. demerphq was using [], not ().

        In list context () does indeed interpolate as "nothing".