in reply to Re^3: A Melancholy Monkday
in thread A Melancholy Monkday
I do not think that context is a flaw in Perl 5. I believe that reverse's context dependence in particular a flaw.The flaw is not, in my humble opinion, that it depends on context but that does both depend on its own context and suggest by its name that it reverses either a string or a list, whatever is passed. Another weird context thing is:
The flaw is that the degree of context vs. valence dependence is rather arbitrary comparing different list operators and subroutines. It is like in German and some other indoeuropean languages, learners must memorize which word is of which gender.scalar qw(this is a list); # returns 'list', but: scalar map { $_ } qw(this is a list); # returns 4 # map construct an anonymous array kind of thing # and an array returns the number of the contained items # in scalar context. But user-defined subroutines again: sub func { qw(this is a), shift } scalar func("foo"); # returns "foo" out of the list returned # by func subroutine
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: A Melancholy Monkday
by Anonymous Monk on Feb 03, 2014 at 22:39 UTC | |
by flowdy (Scribe) on Feb 04, 2014 at 19:54 UTC |