Skip to content

[PATCH] Document for(;;) and while() in perlsyn #13895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
p5pRT opened this issue Jun 2, 2014 · 7 comments
Closed

[PATCH] Document for(;;) and while() in perlsyn #13895

p5pRT opened this issue Jun 2, 2014 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 2, 2014

Migrated from rt.perl.org#122015 (status was 'resolved')

Searchable as RT122015$

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

From [email protected]

for(;;) and while() do not appear to be documented in core; attached
is a patch to perlsyn to at least reference them somewhere, for
discussion.

Summary of my perl5 (revision 5 version 20 subversion 0) configuration​:
  Commit id​: d7d4ece
  Platform​:
  osname=linux, osvers=3.13.0-24-generic, archname=x86_64-linux
  uname='linux pmubuntu 3.13.0-24-generic #46-ubuntu smp thu apr 10
19​:11​:08 utc 2014 x86_64 x86_64 x86_64 gnulinux '
  config_args='-DDEBUGGING -des'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
  optimize='-O2 -g',
  cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.8.2', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu
/lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
  libs=-lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.19'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib
-fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING HAS_TIMES PERLIO_LAYERS
  PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
  PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
  USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES
  USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
  Built under linux
  Compiled at May 29 2014 00​:05​:39
  @​INC​:
  /usr/local/lib/perl5/site_perl/5.20.0/x86_64-linux
  /usr/local/lib/perl5/site_perl/5.20.0
  /usr/local/lib/perl5/5.20.0/x86_64-linux
  /usr/local/lib/perl5/5.20.0
  /usr/local/lib/perl5/site_perl/5.19.9
  /usr/local/lib/perl5/site_perl/5.19.5
  /usr/local/lib/perl5/site_perl/5.18.1
  /usr/local/lib/perl5/site_perl
  .

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

From [email protected]

0001-Document-empty-conditional-in-for-while.patch
From 62b13428938b1bde786bf346daacb1b5069dd610 Mon Sep 17 00:00:00 2001
From: Peter Martini <[email protected]>
Date: Mon, 2 Jun 2014 07:16:59 -0400
Subject: [PATCH] Document empty conditional in for/while

An empty conditional in both for and while has been treated
as true since perl 1.0.  This has a clear analogue in C/C++
in the case of for(;;), but while() is not legal C and should
be documented.
---
 pod/perlsyn.pod | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod
index 244372c..cea4d50 100644
--- a/pod/perlsyn.pod
+++ b/pod/perlsyn.pod
@@ -429,6 +429,21 @@ those variables is exactly the C<for> loop (the body of the loop
 and the control sections).
 X<my>
 
+As a special case, if the test in the C<for> loop (or the corresponding
+C<while> loop) is empty, it is treated as true.  That is, both
+
+    for (;;) {
+	...
+    }
+
+and
+
+    while () {
+	...
+    }
+
+are treated as infinite loops.
+
 Besides the normal array index looping, C<for> can lend itself
 to many other interesting applications.  Here's one that avoids the
 problem you get into if you explicitly test for end-of-file on
-- 
1.9.1

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

From @jkeenan

On Mon Jun 02 04​:23​:46 2014, pcm wrote​:

for(;;) and while() do not appear to be documented in core; attached
is a patch to perlsyn to at least reference them somewhere, for
discussion.

Seems reasonable to me. Any objection to applying?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2014

From @khwilliamson

On Mon Jun 02 13​:40​:32 2014, jkeenan wrote​:

On Mon Jun 02 04​:23​:46 2014, pcm wrote​:

for(;;) and while() do not appear to be documented in core; attached
is a patch to perlsyn to at least reference them somewhere, for
discussion.

Seems reasonable to me. Any objection to applying?

Thank you very much.
Jim Keenan

+1 to applying
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2014

From @jkeenan

Pushed to blead in commit 62bd8e4. Resolving ticket.

Thank you very much.
Jim Keenan

@p5pRT p5pRT closed this as completed Jun 24, 2014
@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2014

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant