in reply to Re^14: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands
If what happened was really "pass by reference" in a classical sense, one would be able to operate on the passed variable by the lexical or localized variable's name without regard for the reference, only it would effect the original. That's not what happens. You can force the subroutine, via the prototype mechanism, to take a reference to the argument but you still have to treat it as a reference.
sub foo (\@) { print pop @{$_[0]}; }; @bar = qw( foo bar ); foo @bar;
BTW, lists are not precluded from being first-class simply by not being named, either, as JavaFan pointed out as a disqualification earlier. Anonymous lists, anonymous functions, and anonymous closures are first-class objects in some languages.
As I said before, what constitutes a first-class value can vary by language. In Perl, one could consider arrays and hashes as first-class, but one could make arguments against that classification as well.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^16: If you believe in Lists in Scalar Context, Clap your Hands
by JavaFan (Canon) on Oct 29, 2008 at 18:38 UTC | |
by mr_mischief (Monsignor) on Oct 29, 2008 at 19:09 UTC |