Re: [perl #90906] smartmatch PATCH 1 of 2 for 5.14.1: perlop.pod

[email protected] (Tom Christiansen)
Newsgroups perl.pod-people,perl.perl5.porters
Message-ID <15862.1305729061@chthon>
Chip Salzenberg <[email protected]> wrote
   on Tue, 17 May 2011 18:35:04 PDT: 

>> The 65-column nroff manpage limit is severely troublesome.

> Shirley, this is an obsolete requirement.  Heck, my TRS-80 Model I
> almost-toy could show 64 columns.  In 1978.

Manpages *can* get linewrapped or snipped at 65 columns.  Currently
they seem actually to work on at least one system, but I haven't 
done any checking around.
 
> Why not 100 at least, these days?

Well, 100 isn't actually enough.  See below.

But I very much feel the table would be easier to read this way:

             1         2         3         4         5         6         7         8         9         10        11        12        13
    1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789

    Left      Right      Description and pseudocode                        Like
    ==============================================================================================================================
    Any       undef      check whether Any is undefined                    !defined Any
    Any       Object     invoke ~~ overloading on Object, or die

    ARRAY1    ARRAY2     recurse on paired elements of ARRAY1 and ARRAY2[2] ARRAY1[0] ~~ ARRAY2[0] && ARRAY1[1] ~~ ARRAY2[1] && ...
    HASH      ARRAY      any ARRAY elements exist as HASH keys              grep { exists HASH->{$_} } ARRAY
    Regexp    ARRAY      any ARRAY elements pattern match Regexp            grep { /Regexp/ } ARRAY
    undef     ARRAY      undef in ARRAY                                     grep { !defined } ARRAY
    Any       ARRAY      smart match each ARRAY element[3]                  grep { Any ~~ $_ } ARRAY

    HASH1     HASH2      all same keys in both HASHes                       keys HASH1 == grep { exists HASH2->{$_} } keys HASH1
    ARRAY     HASH       any ARRAY elements exist as HASH keys              grep { exists HASH->{$_} } ARRAY
    Regexp    HASH       any HASH keys pattern match Regexp                 grep { /Regexp/ } keys HASH
    undef     HASH       always false (undef can't be a key)                0 == 1
    Any       HASH       HASH key existence                                 exists HASH->{Any}

    ARRAY     CODE       sub returns true on all ARRAY elements[1]          !grep { !CODE->($_) } ARRAY
    HASH      CODE       sub returns true on all HASH keys[1]               !grep { !CODE->($_) } keys HASH
    Any       CODE       sub passed Any returns true                        CODE->(Any)

    ARRAY     Regexp     any ARRAY elements match Regexp                    grep { /Regexp/ } ARRAY
    HASH      Regexp     any HASH keys match Regexp                         grep { /Regexp/ } keys HASH
    Any       Regexp     pattern match                                      Any =~ /Regexp/

    Object    Any        invoke ~~ overloading on Object, or fall back to...
    Any       Num        numeric equality                                   Any == Num
    Num       nummy[4]   numeric equality                                   Num == nummy
    undef     Any        check whether undefined                            !defined(Any)
    Any       Any        string equality                                    Any eq Any

Than I would this:

             1         2         3         4         5         6         7         8
    12345678901234567890123456789012345678901234567890123456789012345678901234567890

    Left      Right      Description and pseudocode
    ===============================================================
    Any       undef      check whether Any is undefined
                   like: !defined Any

    Any       Object     invoke ~~ overloading on Object, or die

  Right operand is an ARRAY:

    Left      Right      Description and pseudocode
    ===============================================================
    ARRAY1    ARRAY2     recurse on paired elements of ARRAY1 and ARRAY2[2]
                   like: (ARRAY1[0] ~~ ARRAY2[0]) && (ARRAY1[1] ~~ ARRAY2[1]) && ...
    HASH      ARRAY      any ARRAY elements exist as HASH keys
                   like: grep { exists HASH->{$_} } ARRAY
    Regexp    ARRAY      any ARRAY elements pattern match Regexp
                   like: grep { /Regexp/ } ARRAY
    undef     ARRAY      undef in ARRAY
                   like: grep { !defined } ARRAY
    Any       ARRAY      smart match each ARRAY element[3]
                   like: grep { Any ~~ $_ } ARRAY

  Right operand is a HASH:

    Left      Right      Description and pseudocode
    ===============================================================
    HASH1     HASH2      all same keys in both HASHes
                   like: keys HASH1 == grep { exists HASH2->{$_} } keys HASH1
    ARRAY     HASH       any ARRAY elements exist as HASH keys
                   like: grep { exists HASH->{$_} } ARRAY
    Regexp    HASH       any HASH keys pattern match Regexp
                   like: grep { /Regexp/ } keys HASH
    undef     HASH       always false (undef can't be a key)
                   like: 0 == 1
    Any       HASH       HASH key existence
                   like: exists HASH->{Any}

  Right operand is CODE:

    Left      Right      Description and pseudocode
    ===============================================================
    ARRAY     CODE       sub returns true on all ARRAY elements[1]
                   like: !grep { !CODE->($_) } ARRAY
    HASH      CODE       sub returns true on all HASH keys[1]
                   like: !grep { !CODE->($_) } keys HASH
    Any       CODE       sub passed Any returns true
                   like: CODE->(Any)

  Right operand is a Regexp:

    Left      Right      Description and pseudocode
    ===============================================================
    ARRAY     Regexp     any ARRAY elements match Regexp
                   like: grep { /Regexp/ } ARRAY
    HASH      Regexp     any HASH keys match Regexp
                   like: grep { /Regexp/ } keys HASH
    Any       Regexp     pattern match
                   like: Any =~ /Regexp/

  Other:

    Left      Right      Description and pseudocode
    ===============================================================
    Object    Any        invoke ~~ overloading on Object, or fall back to...

    Any       Num        numeric equality
                    like: Any == Num
    Num       nummy[4]    numeric equality
                    like: Num == nummy
    undef     Any        check whether undefined
                    like: !defined(Any)
    Any       Any        string equality
                    like: Any eq Any

Suggestions?

--tom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.