[comp.lang.perl] perl man page

dwork@brahms.amd.com (Jeff Dwork) (08/14/90)

Two man page bugs:

>     splice(ARRAY,OFFSET)
>
>                  push(@a,$x,$y)                splice(@a,$#x+1,0,$x,$y)

Shouldn't that be `$#a'?

>
>     As mentioned earlier, if any list operator (print, etc.)  or
>     any  unary  operator  (chdir,  etc.)  is  followed by a left
>     parenthesis as the next token on the same line, the operator
>     and  arguments within parentheses are taken to be of highest
>     precedence, just like a normal function call.  Examples:
>
>          chdir $foo || die;       # (chdir $foo) || die
>          chdir($foo) || die;      # (chdir $foo) || die
>          chdir ($foo) || die;     # (chdir $foo) || die
>          chdir +($foo) || die;    # (chdir $foo) || die
>
>     but, because * is higher precedence than ||:
>
>          chdir $foo * 20;         # chdir ($foo * 20)
>          chdir($foo) * 20;        # (chdir $foo) * 20
>          chdir ($foo) * 20;       # (chdir $foo) * 20
>          chdir +($foo) * 20;      # chdir ($foo * 20)

Shouldn't it read:
     but, because * is higher precedence than +:

Or am I missing something here?

Version is:
	$Header: perly.c,v 3.0.1.5 90/03/27 16:20:57 lwall Locked $
	Patch level: 18


Two requests:

	The man page lists only operators that differ from those in C.  Many
of our users (and potential users) do little or no C programming.  How about
adding the rest of the operators to the man page?

	The section on regular expressions requires one to also read the
regexp routine documentation.  Could the relevant sections of regexp(3) be
included in this section?

	These additions would, IMHO, make the man page a better reference for
the novice/infrequent user of perl.
--
Jeff Dwork			|  408-749-2356 	|  dwork@AMD.COM
Advanced Micro Devices, M/S 45	|---------------------------------------
PO Box 3453			|  The above opionions are mine,
Sunnyvale, Ca 94088		|  not AMD's.

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/14/90)

In article <1990Aug13.194249.6156@amd.com> dwork@brahms.amd.com (Jeff Dwork) writes:
: Two man page bugs:
: 
: >     splice(ARRAY,OFFSET)
: >
: >                  push(@a,$x,$y)                splice(@a,$#x+1,0,$x,$y)
: 
: Shouldn't that be `$#a'?

No.  That would insert $x and $y before the last element.

: >     As mentioned earlier, if any list operator (print, etc.)  or
: >     any  unary  operator  (chdir,  etc.)  is  followed by a left
: >     parenthesis as the next token on the same line, the operator
: >     and  arguments within parentheses are taken to be of highest
: >     precedence, just like a normal function call.  Examples:
: >
: >          chdir $foo || die;       # (chdir $foo) || die
: >          chdir($foo) || die;      # (chdir $foo) || die
: >          chdir ($foo) || die;     # (chdir $foo) || die
: >          chdir +($foo) || die;    # (chdir $foo) || die
: >
: >     but, because * is higher precedence than ||:
: >
: >          chdir $foo * 20;         # chdir ($foo * 20)
: >          chdir($foo) * 20;        # (chdir $foo) * 20
: >          chdir ($foo) * 20;       # (chdir $foo) * 20
: >          chdir +($foo) * 20;      # chdir ($foo * 20)
: 
: Shouldn't it read:
:      but, because * is higher precedence than +:

No, that's not what the + is doing there.  The point is that chdir (as a
unary operator) has a precedence intermediate between || and *, so * and ||
don't behave the same after chdir.

: Two requests:
: 
: 	The man page lists only operators that differ from those in C.  Many
: of our users (and potential users) do little or no C programming.  How about
: adding the rest of the operators to the man page?
:
: 	The section on regular expressions requires one to also read the
: regexp routine documentation.  Could the relevant sections of regexp(3) be
: included in this section?

They'll be in the book.  I don't know about the man page--I'm already
accused of putting too much there.  And there's a fine minimalistic tradition
of man pages referring to other man pages.  After all, redundancy is Evil.
Say that with me.  Redundancy is Evil.  Again.  Redundancy is Evil.  Again...

Now if Tom would just upgrade his man program to a generalized hypertext
system, we wouldn't have this problem...   :-)

Larry

dwork@brahms.amd.com (Jeff Dwork) (08/15/90)

In article <9131@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
>In article <1990Aug13.194249.6156@amd.com> dwork@brahms.amd.com (Jeff Dwork) writes:
>: Two man page bugs:
>: 
>: >     splice(ARRAY,OFFSET)
>: >
>: >                  push(@a,$x,$y)                splice(@a,$#x+1,0,$x,$y)
>: 
>: Shouldn't that be `$#a'?
>
>No.  That would insert $x and $y before the last element.
>

What I meant was `$#a+1' as opposed to `$#x+1'.  It seems to me that `$#x'
refers to the last index of array @x, which has nothing to do with scalar $x.
Or am I still confused?

Thanks,
	Jeff
--
Jeff Dwork			|  408-749-2356 	|  dwork@AMD.COM
Advanced Micro Devices, M/S 45	|---------------------------------------
PO Box 3453			|  The above opionions are mine,
Sunnyvale, Ca 94088		|  not AMD's.

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/15/90)

In article <1990Aug14.193300.7083@amd.com> dwork@brahms.amd.com (Jeff Dwork) writes:
: In article <9131@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
: >In article <1990Aug13.194249.6156@amd.com> dwork@brahms.amd.com (Jeff Dwork) writes:
: >: Two man page bugs:
: >: 
: >: >     splice(ARRAY,OFFSET)
: >: >
: >: >                  push(@a,$x,$y)                splice(@a,$#x+1,0,$x,$y)
: >: 
: >: Shouldn't that be `$#a'?
: >
: >No.  That would insert $x and $y before the last element.
: >
: 
: What I meant was `$#a+1' as opposed to `$#x+1'.  It seems to me that `$#x'
: refers to the last index of array @x, which has nothing to do with scalar $x.
: Or am I still confused?

No, you're absolutely right.

Larry

weisberg@hpccc.HP.COM (Len Weisberg) (08/16/90)

I thought I'd give Jeff first crack at clarifying his comments, but he seems 
to have backed down on the second one:

Regarding the following from the manual:
>     As mentioned earlier, if any list operator (print, etc.)  or
>     any  unary  operator  (chdir,  etc.)  is  followed by a left
>     parenthesis as the next token on the same line, the operator
>     and  arguments within parentheses are taken to be of highest
>     precedence, just like a normal function call.  Examples:
>
>          chdir $foo || die;       # (chdir $foo) || die
>          chdir($foo) || die;      # (chdir $foo) || die
>          chdir ($foo) || die;     # (chdir $foo) || die
>          chdir +($foo) || die;    # (chdir $foo) || die
>
>     but, because * is higher precedence than ||:
>
>          chdir $foo * 20;         # chdir ($foo * 20)
>          chdir($foo) * 20;        # (chdir $foo) * 20
>          chdir ($foo) * 20;       # (chdir $foo) * 20
>          chdir +($foo) * 20;      # chdir ($foo * 20)

Jeff wrote
: Shouldn't it read:
:      but, because * is higher precedence than +:

I agree with Larry that that misses the point.
My suggestion is that it should read:

      but, because * has higher precedence than chdir :

Larry writes:
> The point is that chdir (as a
> unary operator) has a precedence intermediate between || and *, so * and ||
> don't behave the same after chdir.

This point might be further clarified by adding before the first 4 indented 
lines something like:
      Because || has lower precedence than chdir we have:

----------

Now, repeat after me:
Tasteful redundancy is Golden.

- Len Weisberg - HP Corp Computing & Services - weisberg@corp.HP.COM

worley@compass.com (Dale Worley) (08/16/90)

The manual reads:

    precedence, just like a normal function call.  Examples:

         chdir $foo || die;       # (chdir $foo) || die
         chdir($foo) || die;      # (chdir $foo) || die
         chdir ($foo) || die;     # (chdir $foo) || die
         chdir +($foo) || die;    # (chdir $foo) || die

    but, because * is higher precedence than ||:

         chdir $foo * 20;         # chdir ($foo * 20)
         chdir($foo) * 20;        # (chdir $foo) * 20
         chdir ($foo) * 20;       # (chdir $foo) * 20
         chdir +($foo) * 20;      # chdir ($foo * 20)

Shouldn't the first one have the comment "because chdir is higher
precedence than ||", and the second "because * is higher precedence
than chdir"?  To the naive, it's not immediately obvious why "chdir
$foo || die" is parsed differently than "chdir $f00 * 20".

Dale Worley		Compass, Inc.			worley@compass.com
--
Captain's Log, Star-date 6701.9:  The weather is fine.  Beam down Yeoman
Rand and a six-pack.