in reply to Re^6: What does _ mean?
in thread What does _ mean?

A google code search for '" -d " lang:perl' produces 108,000 results while a search for '"(_)" lang:perl' produces 6,000.

I'll grant you, some of those -d results are spurious, someone documenting a '-d' command line switch and so on.

Let's try and wrap this up. Do you agree with the statement, "-d $filename" is clearer than "-d (_)"? I'll agree that "-d (_)" is better for performance than "-d $filename". I'll even agree that my first post was stupid. OK?

Replies are listed 'Best First'.
Re^8: What does _ mean?
by ikegami (Patriarch) on Feb 04, 2009 at 18:02 UTC

    Do you agree with the statement, "-d $filename" is clearer than "-d (_)"?

    No. The meaning of neither is ambiguous. You may not know what they do, but I don't see how you could possibly think they do something than what they do.

      The "problem" is that the underscore in this case is an obscure feature. Most people will understand -d $filename while many will have to look up what the underscore does before they understand what -d (_) does. Use of obscure features makes code harder to understand and thus should be avoided unless there is a good reason for it. At least I think that's what pileofrogs meant.

      Elda Taluta; Sarks Sark; Ark Arks

        thus should be avoided unless there is a good reason for it.

        What should I use instead, a class people would have to look up anyway?

        Remember, it's not -d _ vs -d $filename. They don't do the same thing. It's -d _ vs $stat->mode & 0170000 == 040000 or something that's not even part of Perl.

      Okay, fair enough.

      What name would you give to the quality of code that enables one to read it quickly in poor conditions (half-asleep, drunk, etc...)?

        Clear, even quicker if it's simplistic.
Re^8: What does _ mean?
by massa (Hermit) on Feb 04, 2009 at 22:48 UTC
    Your results are inconclusive, as -d _ without the parentheses would be enough. Maybe if you pit the total of -X $something against the total of -X _ plus -X(_) plus -X (_) etc you would have a better idea.

    Anyway, the point is moot because (IMHO!!) this:

    if( -x $filename and -d _ )
    is better, cleaner, more concise, and clearer, than
    if( -x $filename and -d $filename )
    because I am used to Perl and I know that anything that has _ in it means that thing we were just talking about, i.e., the Topic.
    []s, HTH, Massa (κς,πμ,πλ)