Why no "perldoc -f for/foreach/while"?

U

usenet

perldoc (5.8.6) says "No documentation for..."

perldoc -f for
perldoc -f foreach
perldoc -f while

But related commands such as next/last/redo/continue ARE documented.

Also not found are:

perldoc -f if
perldoc -f unless

Odd. Whyizzat?
 
M

Matt Garrish

perldoc (5.8.6) says "No documentation for..."

perldoc -f for
perldoc -f foreach
perldoc -f while

But related commands such as next/last/redo/continue ARE documented.

Also not found are:

perldoc -f if
perldoc -f unless

Odd. Whyizzat?

From "perldoc --help":

<quote>
perldoc [options] -f BuiltinFunction
....
BuiltinFunction
is the name of a perl function. Will extract documentation from
`perlfunc'.
</quote>

Conditionals and loop controls are not considered functions/commands and are
not in perlfunc; the rest are. Or are you arguing that they should be?

Matt
 
U

usenet

Matt said:
Conditionals and loop controls are not considered functions/commands
and are not in perlfunc; the rest are.

I consider next/last/redo/continue to be "loop controls" - and these
ARE documented in perlfunc. I think it's odd these are documented with
'perldoc -f' when while/for are not.
Or are you arguing that they should be?

I'm just wondering where they ARE documented.

Although, now that you mention it... yeah, I think they ought to be
documented here; I see no real reason why these could not be considered
"Keywords related to the control flow of your perl program." It seems
to me that while() controls the flow of my program...
 
M

Matt Garrish

I consider next/last/redo/continue to be "loop controls" - and these
ARE documented in perlfunc. I think it's odd these are documented with
'perldoc -f' when while/for are not.


I'm just wondering where they ARE documented.

perlsyn

I see next/last/redo/continue as commands that can be used to control loop
behaviour, and hence their inclusion, for what it's worth.

Matt
 
T

Tassilo v. Parseval

Also sprach Keith Keller:
I agree with your statement, but it is still a little confusing (esp. to
someone new to programming, who doesn't necessarily see a difference
between functions and conditionals) to have next/last/redo but not if/
unless/for/while. Maybe a new switch might accomodate a quick lookup of
if without polluting perldoc -f?

'next', 'last' and 'redo' are no more functions than 'if', 'unless',
'for' and 'while'. All of these are keywords but not built-in functions.
Hence David's point is totally valid: The fact that the loop-control
keywords are in perlfunc whereas the actual constructors of these loop-
and control-structures are not is rather inconsistent.

Tassilo
 
L

Lukas Mai

Tassilo v. Parseval said:
'next', 'last' and 'redo' are no more functions than 'if', 'unless',
'for' and 'while'. All of these are keywords but not built-in functions.
Hence David's point is totally valid: The fact that the loop-control
keywords are in perlfunc whereas the actual constructors of these loop-
and control-structures are not is rather inconsistent.

It makes sense to me because you can use next/last/redo in expressions,
which makes them function-like:

$_ = next LABEL;
redo();

Sure, these "functions" don't return but that doesn't change the fact
that they're parsed like the rest of perlfunc.

HTH, Lukas
 
I

Ilya Zakharevich

[I see only parts of the discussion in our feed. Sorry if I missed something]

[A complimentary Cc of this posting was sent to
I consider next/last/redo/continue to be "loop controls" - and these
ARE documented in perlfunc. I think it's odd these are documented with
'perldoc -f' when while/for are not.

IMO, perldoc -f should be able to find ALL the words special to Perl.
If you are interested in the (possibly non-complete) list, look in the
table cperl-short-docs in Emacs CPerl mode.

Hope this helps,
Ilya
 
D

Dr.Ruud

Tad McClellan:
usenet@DavidFilmer:


Because "control structures" are not "functions".

Let's find a new meaning for -f then, like
feature/fetch/figure/find/fish/fix/flash/flesh-out/fling/flip/follow/for
epart/foreplay/foreshadow/foretell/formal/formulate/functional/fundament
al/etc.

I guess 'flash' and 'flesh-out' are nice limits of what to expect
from -f.
I like 'flash'.
 
B

Bart Lateur

Ilya said:
IMO, perldoc -f should be able to find ALL the words special to Perl.

I agree... perldoc -f only searches through perlfunc, and I think that's
too limited. It's unfortunate that operators like "and" and control
keywords like "unless" aren't found. Perlfunc is the bulk of the
keywords to perl, but not everything.

Whenever I go search for "unless" in the real place where it is
documented, "perlsyn", I'm still amazed at how thick as mud the
description actually is, compared to the to the point descriptions in
perlfunc.

It apparently is also incomplete. Look at this list in perlsyn:

The following compound statements may be used to control flow:

if (EXPR) BLOCK
if (EXPR) BLOCK else BLOCK
if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
LABEL while (EXPR) BLOCK
LABEL while (EXPR) BLOCK continue BLOCK
LABEL for (EXPR; EXPR; EXPR) BLOCK
LABEL foreach VAR (LIST) BLOCK
LABEL foreach VAR (LIST) BLOCK continue BLOCK
LABEL BLOCK continue BLOCK

Where's "unless"? Where's "until"?

It also suggests you can't have an "elsif" without an "else".
 
A

Anno Siegel

Bernard El-Hagin said:

Currently "-f" means "function" and using it to display keywords
that aren't functions would be a stretch. If we re-interpret it
as meaning "flash" (as in flash card, I suppose), we could make it
work with all keywords.

The hard part is, of course, changing perldoc so that this works.
The "-f" option draws on the rather strict formatting of perlfunc
to isolate individual descriptions. For other keywords, perlsyn
and others would have to be tapped into. These are rather free-
form and can't be used that way without refactoring.

Anno
 
J

John W. Krahn

Anno said:
Currently "-f" means "function" and using it to display keywords
that aren't functions would be a stretch.

It used to mean "function" back before Perl5 but now that "functions" are
actually operators (see: Terms and List Operators in perlop.pod) it would seem
that "Terms, Operators And Keywords" would be a more appropriate title for the
perlfunc.pod document.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top