Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^4: A Melancholy Monkday

by flowdy (Scribe)
on Feb 03, 2014 at 22:22 UTC ( #1073271=note: print w/replies, xml ) Need Help??

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:
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
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.

Replies are listed 'Best First'.
Re^5: A Melancholy Monkday
by Anonymous Monk on Feb 03, 2014 at 22:39 UTC

    It is like in German and some other indoeuropean languages, learners must memorize which word is of which gender.

    Um, as someone who speeks some of those languages -- its nothing like that ; gender doesn't change a verb to a noun (and vice versa), or subject to object(sentence structure ), or emmentaler to fahrvergnügen

    The same is true in perl, if you don't grasp the basics, its all greek to you, even german

      You're right in that I should better say nouns when I mean nouns, not words.

      if you don't grasp the basics, its all greek to you

      Do you refer specifically to the map-vs.-subroutines thing I demonstrated? Then no, I wouldn't consider a basic must-know that map and other list operators(?) are array-like, subroutines however list-like in regard to what they return.

      But even as a native speaker of German (and hobby linguist) I find a pretty bucket of WTFs in its grammar, I presume I must have had a really hard time cramming its basics while in womb ;-). But it is not the topic. Just want to say that English is perfect, as well as German and any other natural language is. Programming languages are different here. They should evolve based on reason, much less on convention. The more they are based on convention and subtleties like what I exemplified, the more time the programmer must invest not in thinking and understanding the language and the machine at last logically, but in hacking by try and error. Of the former the return of investment would be a bit larger since machines are logical as well.

      I do not want to argue against Perl. It fits for people like me who like languages and I really love programing in it most time. But after all, to the novice it provokes an illusion of a machine that kind of understands him or her. The learning path from Perl to another language stricter by design is more frustrating than vice versa, I am afraid.

      To put it short: I do not explicitly recommend Perl to novices of programing because of this and if others doing so is the reason why it is not widely used (learned) any more, it is okay. I feel I am better off writing my own code in a way that as few knowledge of the downsides of the Perl language as possible is required to understand the program, and demonstrating every once in a while its upsides, e.g. the use of map in list context (edit: which also means never ever as a subroutine return value as you have limited control over which context the sub is called in). If my code arouses curiosity on Perl programing without my advocating it, well, that is worth the try.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073271]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2018-02-23 07:22 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (300 votes). Check out past polls.