Skip to content
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

null conditionals should not be allowed #1152

Closed
p5pRT opened this issue Feb 8, 2000 · 1 comment
Closed

null conditionals should not be allowed #1152

p5pRT opened this issue Feb 8, 2000 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Feb 8, 2000

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

Searchable as RT2115$

@p5pRT
Copy link
Author

p5pRT commented Feb 8, 2000

From pbdb_test@rfi.net

For some reason, Perl accepts a while loop with an empty conditional.
  while ( ) { print "TRUE"; sleep 1; }
results in a big list of TRUEs. This is odd in several ways​:

  1) Everything else (until, if, unless...) is a syntax error with an
  empty condition.
  2) The empty condition of a while loop is TRUE! If anything I would
  expect false.
  3) There's no warning.

At minimum there should be a warning, at best it should be made a
syntax error.

This looks like a documentation problem.

Here's another intersting problem​:

do { print "TRUE"; sleep 1 } while ();
This produces one iteration of TRUE.

do { print "TRUE"; sleep 1 } until ();
This produces an infinite loop.

Again, the oddness​:
  1) Unlike with while () {...}, the null condition is false!
  2) Again, no warning.

IMHO do {...} while () and do {...} until () should both be syntax
errors, or at least warnings.

Unless there's a backwards compatibility issue, all instances of an
empty conditional should probably be a syntax error. I can't think of
any time when it would be useful.

If I'm feeling brave I'll submit a patch.

PS This problem occurs under 5.005_03 and 5.005_62

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=macOS, osvers=2.2.7, archname=i686-linux
  uname='linux athens 2.2.7 #2 smp mon may 10 23​:17​:01 edt 1999 i686 unknown '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='gcc', optimize='-O6', gccversion=egcs-2.91.66 19990314 (egcs-1.1.2 release)
  cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  stdchar='char', d_stdstdio=undef, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='gcc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
  libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Built under linux
  Compiled at Jul 29 1999 00​:29​:00
  %ENV​:
  PERL5LIB="/home/schwern/lib/perl5/site_perl/5.005​:/web/sites/test/mp"
  @​INC​:
  /home/schwern/lib/perl5/site_perl/5.005/i686-linux
  /home/schwern/lib/perl5/site_perl/5.005
  /web/sites/test/mp
  /usr/lib/perl5/i686-linux
  /usr/lib/perl5
  /usr/lib/perl5/site_perl/5.005/i686-linux
  /usr/lib/perl5/site_perl/5.005
  .

Summary of my perl5 (revision 5.0 version 5 subversion 62) configuration​:
  Platform​:
  osname=linux, osvers=2.2.10, archname=i686-linux
  uname='linux athens 2.2.10 #3 smp mon aug 2 16​:48​:09 edt 1999 i686 unknown '
  config_args=''
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  use64bits=undef usemultiplicity=undef
  Compiler​:
  cc='cc', optimize='-g', gccversion=2.95.2 19990906 (prerelease)
  cppflags='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include -DDEBUGGING_OPS -DDEBUGGING_MSTATS -fno-strict-aliasing'
  ccflags ='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include -DDEBUGGING_OPS -DDEBUGGING_MSTATS -fno-strict-aliasing'
  stdchar='char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
  libc=/lib/libc-2.1.2.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING
  Built under linux
  Compiled at Oct 16 1999 16​:16​:24
  %ENV​:
  PERL5LIB="/home/schwern/lib/perl5/site_perl/5.005​:/web/sites/test/mp"
  @​INC​:
  /home/schwern/lib/perl5/site_perl/5.005/i686-linux
  /home/schwern/lib/perl5/site_perl/5.005
  /web/sites/test/mp
  /usr/local/perl5.005_62/lib/5.00562/i686-linux
  /usr/local/perl5.005_62/lib/5.00562
  /usr/local/perl5.005_62/lib/site_perl/5.00562/i686-linux
  /usr/local/perl5.005_62/lib/site_perl
  .

--

Michael G Schwern schwern@​pobox.com
  http​://www.pobox.com/~schwern
  /(?​:(?​:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

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

No branches or pull requests

1 participant