Re: RFC 110 (v3) counting matches

[email protected] (Tom Christiansen)
Newsgroups perl.perl6.language.regex
Message-ID <19289.967572436@chthon>
>But, for "crying out loud!", then what the hell do we need "scalar" for?
>You can accomplish the same thing like this:

>   $num = @array;
>   print "Got $num elements";

Wrong.  You just wasted a scalar needlessly, which ()= doesn't
do.  Of course, you *don't* need scalar() there.

    print "Got " . @array . " elements";

>"scalar" makes things easy. So does something like "list". This

>   $stuff = () = $r =~ /crap/shit/;

>Doesn't make anything easy.

Goodness, it certainly does.  It's loads easier than learning a new buzz^Wkeyword
or a new switch, because you already know it.

>> Perl does context.  Perl does *IMPLICIT* context.  Cope.

>Great. Then let's drop "scalar" to be consistent. This can be done
>completely implicitly, right?

There are no anonymous scalars.  You'd at best have to write

    foo(scalar bar())

as something more like

    foo(do { my $x = bar() })

which is lame.   However, if foo($) is thus "prototyped",
you need but write

    foo( () = bar() )

to get bar() to be called in list context.  This is wholly intuitive.
If it isn't, you need to review how 

    my($x) 

works--once again.

--tom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.