Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^5: magic-diamond <> behavior -- WHAT?!

by JavaFan (Canon)
on Oct 30, 2008 at 10:14 UTC ( #720436=note: print w/replies, xml ) Need Help??

in reply to Re^4: magic-diamond <> behavior -- WHAT?!
in thread magic-diamond <> behavior -- WHAT?!

I know now, but how about the uninformed?
There will always be uninformed people. That's why there's documentation. Dumbing down a language for the uninformed cripples a language. It's as useful as turning cars into bumper cars, just because someone uninformed sits behind the wheel.
  • Comment on Re^5: magic-diamond <> behavior -- WHAT?!

Replies are listed 'Best First'.
Re^6: magic-diamond <> behavior -- WHAT?! (boggle)
by tye (Sage) on Oct 30, 2008 at 13:33 UTC

    Wow. Did you really write that? The words are right there, and yet I still find their existance dubious. (:

    Perhaps you should go read the documentation. Show me a single example in the documentation of using <> correctly (based on the current implementation) and I'll show a dozen counter-examples where <> is used dangerously in the standard documentation. Of course, your example would have only fairly recently been added, since for the majority of the existence of <>, no such example existed in the standard documentation (and I didn't run into any when I browsed several sections of the latest release of the documentation just hours ago).

    Nobody is proposing crippling anything. Make getting the magical behavior require a tiny extra invocation (-Margv or similar).

    Of course, it is impossible to document how to use -i correctly, but why fix -i when it might require slight modifications to a tiny, tiny fraction of the uses of <> by people who likely bragged about the freaky thing they did when they wrote them?

    Pity the fool who read perlrun, for example, and was extra careful about evily named files by using "find -print0" and followed the helpful suggestion from the standard Perl documentation and pasted and slightly modified to get:

    find /tmp -mtime +7 -print0 | perl -n0e unlink

    into root's crontab to clean out /tmp daily.

    And, no, tainting is not what should be done in such situations. An entry in root's crontab does not need to worry about environment variables being evily set. Proposing taint checking as a band-aid for the fact that something as ubiquitous as -n and -p will leak file names into the execution stream is just silly.

    - tye        

      I fail to see what
      find /tmp -mtime +7 -print0 | perl -n0e unlink
      has to do with magic open.

      In the above fragment, perl reads the files to unlink from STDIN, not from ARGV, and no magic open happens.

        Ah, thanks. I was fooled by -n.

        - tye        

      Maybe tainting is silly, but it is available now, not maybe tomorrow.
Re^6: magic-diamond <> behavior -- WHAT?!
by Anonymous Monk on Oct 30, 2008 at 16:31 UTC
    There will always be uninformed people. That's why there's documentation.

    So you agree that either the language or the documentation should be fixed!

      Well, I think magic open should stay as is, and I know that it's documented, so I don't see a need to fix the documentation.

      But documentation patches are about the easiest patches you can make, and the most likely to be accepted. If people think the current documentation isn't good enough, by all means, instead of bickering about it, write a patch.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://720436]
[Corion]: And performance linear to the number of registered one-shots doesn't feel that bad. Maybe I should collect statistics on how many callbacks are outstanding ;)
[Corion]: choroba: Yes, but the longer I thought about efficient hashes mapping the event type back to their callbacks, and how to keep them in sync, the more I thought that all that optimization might just not be worth it, even if it's horribly inelegant
[Lady_Aleena]: My biggest problem with hashes at the moment is one with 2,501 keys.
[choroba]: how many event types are there?
[Corion]: Also I found that I can't conveniently weaken an array slot, which also is inconvenient, as I want my one-shots to disappear if the caller discards them
[Corion]: choroba: Currently two or three that my program handles (WWW::Mechanize:: Chrome), but there might be more that become interesting
[Corion]: But I don't expect more than 100 to be active at the same time, so I'm not really sure if there is a not-too-fancy data structure that is maintained with few lines of code where the performance is better than the linear scan ;)
[Corion]: But I should do a mock-up program so that others can see what I'm talking about ;)
[robby_dobby]: Corion: I hope you know all too well that passing around "fancy" datastructures is a recipe for disaster :-)
[robby_dobby]: As in, it's-too-fancy- that-it-will-be- messy-to-handle

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2017-05-29 07:58 GMT
Find Nodes?
    Voting Booth?