Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^9: Near-free function currying in Perl

by dragonchild (Archbishop)
on Nov 18, 2004 at 12:57 UTC ( [id://408755]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Near-free function currying in Perl
in thread Near-free function currying in Perl

I think you're missing the point - 90% of all Perl programmers will never know that you can take a reference to a subroutine. To them, currying is a very advanced technique. In fact, it's almost to the point of inscrutability. It's because of this that I would hesitate to ever use any form of currying at most jobs I've been at, regardless of whether or not I had need for it.

Now, granted, once you grok references, currying is far less complicated than inside-out objects. It's nothing more than fancy caching, just like you said. And, if you know that your maintainers will all be in that 10% of Perl programmers, then it's no more complicated than the map-sort-map of the ST.

As for what Perl might break ... you just might be right. Anything that depends on caller(), B::*, or is sufficiently introspective will probably have issues. But, I've been testing out my Currying implementation based on attributes and it seems to be taking everything I've been throwing at it. A few of the crazier things have been:

# Named closures { my $x = 0; sub inc_x : curry($) { $x += shift } } # run-time binding sub foo : curry($); BEGIN { *foo = sub { print "@_\n" } }

It didn't handle the following, but I think that's because of me screwing up the attribute handler.

sub foo : curry($); my $ref = foo(); $ref->('hello');
That created an infinite loop, but I'm not sure why.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^10: Near-free function currying in Perl
by tilly (Archbishop) on Nov 18, 2004 at 17:23 UTC
    I think you're missing the point - 90% of all Perl programmers will never know that you can take a reference to a subroutine. To them, currying is a very advanced technique.

    If you apply Sturgeon's law, 90% of all Perl programmers are crud. Coincidence? You decide!

    More seriously I'd estimate that over 50% of all Perl programmers have vague plans to learn something about this OO stuff sometime, so to them OO is an advanced technique. It is all a question of perspective. And if you personally are willing to put some energy in, your perspective bears no relationship to what most people experience.

    My perspective is that currying is pretty simple, and it isn't even very hard to teach. Sure, showing a realistic example induces brain lock the first time. But that is temporary and clears up on its own. Since I have no problem taking the energy to spread the knowledge, I have no problem with using it in reasonable doses.

Re^10: Near-free function currying in Perl
by Jenda (Abbot) on Dec 12, 2004 at 23:48 UTC
    90% of all Perl programmers will never know that you can take a reference to a subroutine.

    The question is whether these people deserve to be called "Perl programmers".

    Jenda
    If you're not a programmer, you shouldn't be using Perl. Programming languages are tools for programmers. I apologize if people see that as an elitist statement, but it's true. The mere act of picking up a toolbox doesn't make me an auto mechanic. Would you let me work on your car just because I had a set of tools? I have a pair of scissors at home; you should let me cut your hair.
      -- Greg Bacon

      If you're not a programmer, you shouldn't be using Perl. Programming languages are tools for programmers. I apologize if people see that as an elitist statement, but it's true. The mere act of picking up a toolbox doesn't make me an auto mechanic. Would you let me work on your car just because I had a set of tools? I have a pair of scissors at home; you should let me cut your hair.

      Updated: clarified condition

      Jenda++ -- with a caveat.

      I wouldn't let you cut my hair, or service my car, just because you had a pair of scissors, or a set of tools.

      However, if you wanted to change the oil filter, air filter, wiper blades, or check the tyre pressures on your car and wanted me to give you a few clues as to how you should start, or check what you did afterwards--I'd probably help you with that.

      And if having done a few of the simpler things a few times, you got the taste and confidence to try and tackle something a little more ambicious, I'd probably encourage you.

      And if, over time, it became obvious that you had some sort of flair for what you were doing: you didn't need to ask the same questions over and over; you learnt from your mistakes; displayed the habits of keeping your tools clean and in the right place; laid out the bits you took off in order, so you knew which way to put them back; took the time to label wires and stuff as you went; took responsibility for any mistakes you made--even if based on my advice; then I'd be more than happy to continue to provide what advice I could.

      And, if you eventually got so bitten by the idea that you decided to build your own kit car and asked me to check your work as you went. I'd probably be more that happy to do that too.

      But if you come to me with your nice new toolkit in your hand, and your big pile of kit car bits in the garage and ask me "Where do I start?", I'm probably going to suggest, "I think Joe over the road may know something about wheels and bolts and nuts and stuff."


      Examine what is said, not who speaks.        The end of an era!
      "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
      "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      As BrowserUK said at length, it is obvious that these people do not deserve to be called Perl programmers, but I strongly disagree with your Greg Bacon quote.

      There is a difference between a programmer and someone who sometimes writes programs. However Perl was designed to allow you to get stuff done while only talking baby talk. There are plenty of sysadmins, DBAs, and general users who find Perl helpful even though they are not programmers, and I don't agree with the kind of elitism which would deny them such a useful tool.

      While I can't presume to talk for Larry Wall, the fact that he designed Perl to be productively used while only talking baby talk, and then encouraged this in Programming Perl is strongly suggestive about what he thinks.

      The question is whether these people deserve to be called "Perl programmers".

      No. The question is whether or not they will be paid to be a Perl programmer. If they are, they will fsck up your code. It's a pragmatic matter.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://408755]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-19 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found