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

Inconsistent behaviour of 'while ()' and 'until ()' #8283

Closed
p5pRT opened this issue Jan 16, 2006 · 9 comments
Closed

Inconsistent behaviour of 'while ()' and 'until ()' #8283

p5pRT opened this issue Jan 16, 2006 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 16, 2006

Migrated from rt.perl.org#38254 (status was 'rejected')

Searchable as RT38254$

@p5pRT
Copy link
Author

p5pRT commented Jan 16, 2006

From j.nurick@mvps.org

Created by j.nurick@mvps.org

This is a bug report for perl from j.nurick@​mvps.org,
generated with the help of perlbug 1.35 running under perl v5.8.4.

-----------------------------------------------------------------
DESCRIPTION

'while ()' behaves like 'while (1)', but 'until ()' won't compile.

STEPS TO REPRODUCE

  > perl -e "use warnings; while () {$x++; print $x; last if $x==9; }"
  123456789

  > perl -e "use warnings; until () {$x++; print $x; last if $x==9; }"
  syntax error at -e line 1, near "() "
  syntax error at -e line 1, near "; }"
  Execution of -e aborted due to compilation errors.

COMMENT

After discovering this I asked in clpm where it was documented.
  (Message-ID​: <kqims1l8ilcmfirsdapa8m8dg132s7j7tn@​4ax.com>)
Tassilo v. Parseval pointed me to perly.y
  (Message-ID​: <4316rpF1lepv5U1@​news.dfncis.de>)
and suggested a bug report.

Having 'until ()' behave like 'until (1)' would be useless as the block
would never be executed. But having 'until ()' behave like 'until (0)' would
mirror the
behaviour of 'while'.

Might it also bring a special little TMTOWTDI pleasure if 'while ()' and
'until ()'
had the same effect? (only in the special case of null arguments, of
course).

Perl Info

Flags:
    category=core
    severity=wishlist

Site configuration information for perl v5.8.4:

Configured by ActiveState at Tue Jun  1 11:52:09 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define 
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags 
='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT 
  -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags 
'-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth=C:\PROGRA~1\MICROS~3\VC98\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib 
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib 
msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib 
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib 
msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', 
lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE" 
  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    22751 Update to Test.pm 1.25
    21540 Fix backward-compatibility issues in if.pm


@INC for perl v5.8.4:
    C:/Perl/lib
    C:/Perl/site/lib
    .


Environment for perl v5.8.4:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\BIN\FU\;C:\PERL\BIN\;C:\WINDOWS\SYSTEM32;C:\WINDOWS;C:\WINDOWS\SYSTEM32\WBEM;C:\Program 
Files\Panda Software\Panda Titanium Antivirus 2005\
    PERL_BADLANG (unset)
    SHELL (unset)



@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2006

From charles.e.derykus@boeing.com

'while ()' behaves like 'while (1)', but 'until ()' won't compile.

perl -e "use warnings; while () {$x++; print $x; last if $x==9; }"
123456789

perl -e "use warnings; until () {$x++; print $x; last if $x==9; }"
syntax error at -e line 1, near "() "
syntax error at -e line 1, near "; }"
Execution of -e aborted due to compilation errors.
...

Having 'until ()' behave like 'until (1)' would be useless as the
block would never be executed.
But having 'until ()' > behave like 'until (0)' would mirror the
behaviour of 'while'.

Might it also bring a special little TMTOWTDI pleasure if 'while ()'
and 'until ()'
had the same effect? (only in the special case of null arguments, of
course).
...

And, perversely, this produces no syntax error (5.6.1, 5.8.7)​:

  perl -wle 'do {$x++; print $x; exit if $x==9 } until ()'

--
Charles DeRykus

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2006

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

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2006

From @ysth

On Tue, Jan 17, 2006 at 07​:11​:32AM -0800, DeRykus, Charles E wrote​:

'while ()' behaves like 'while (1)', but 'until ()' won't compile.

perl -e "use warnings; while () {$x++; print $x; last if $x==9; }"
123456789

perl -e "use warnings; until () {$x++; print $x; last if $x==9; }"
syntax error at -e line 1, near "() "
syntax error at -e line 1, near "; }"
Execution of -e aborted due to compilation errors.
...

Having 'until ()' behave like 'until (1)' would be useless as the
block would never be executed.
But having 'until ()' > behave like 'until (0)' would mirror the
behaviour of 'while'.

Might it also bring a special little TMTOWTDI pleasure if 'while ()'
and 'until ()'
had the same effect? (only in the special case of null arguments, of
course).
...

And, perversely, this produces no syntax error (5.6.1, 5.8.7)​:

  perl \-wle 'do \{$x\+\+; print $x; exit if $x==9 \} until \(\)'  

That's different, and parallel to this (which also works)​:

  perl -wle 'until ( () ) {$x++; print $x; exit if $x==9 }'

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2006

From charles.e.derykus@boeing.com

'while ()' behaves like 'while (1)', but 'until ()' won't compile.

perl -e "use warnings; while () {$x++; print $x; last if $x==9; }"
123456789

perl -e "use warnings; until () {$x++; print $x; last if $x==9; }"
syntax error at -e line 1, near "() "
syntax error at -e line 1, near "; }"
Execution of -e aborted due to compilation errors.
...

Having 'until ()' behave like 'until (1)' would be useless as the
block would never be executed.
But having 'until ()' > behave like 'until (0)' would mirror the
behaviour of 'while'.

Might it also bring a special little TMTOWTDI pleasure if 'while ()'
and 'until ()'
had the same effect? (only in the special case of null arguments, of
course).

And, perversely, this produces no syntax error (5.6.1, 5.8.7)​:

  perl \-wle 'do \{$x\+\+; print $x; exit if $x==9 \} until \(\)'  

That's different, and parallel to this (which also works)​:

perl -wle 'until ( () ) {$x++; print $x; exit if $x==9 }'

Ah, you're right. I had forgotten that is different. But, if 'until ()'

is special cased to have 'while ()' semantics, I'll bet someone will ask

why 'for ()' differs and must be 'for (;;)' :)

--
Charles DeRykus

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2006

From j.nurick@mvps.org

And, perversely, this produces no syntax error (5.6.1, 5.8.7)​:

 perl \-wle 'do \{$x\+\+; print $x; exit if $x==9 \} until \(\)'  

IMHO that takes 'until ()' well into bug territory.

No syntax error in 5.8.4, BTW.

John

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2006

From j.nurick@mvps.org

----- Original Message -----
From​: "DeRykus, Charles E via RT" <perlbug-followup@​perl.org>
To​: <j.nurick@​mvps.org>
Sent​: Wednesday, January 18, 2006 12​:00 AM
Subject​: RE​: [perl #38254] Inconsistent behaviour of 'while ()' and 'until
()'

perl -wle 'until ( () ) {$x++; print $x; exit if $x==9 }'

Ah, you're right. I had forgotten that is different. But, if 'until ()'
is special cased to have 'while ()' semantics, I'll bet someone will ask
why 'for ()' differs and must be 'for (;;)' :)

I'll admit the thought had crossed my mind<g>. But as long as Perl has 'for
(@​ary)' as well as the C-style syntax it makes sense to me that 'for ()'
should be an error.

John

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2018

From zefram@fysh.org

"while()" parallels "for(;;)", for which the behaviour of omitting
the conditional expression is copied from C, and is a marginally useful
shorthand. There is no such precedent that would lead to any expectation
of what "until()" ought to mean, nor is it a useful shorthand to make
"until()" behave like the equally-short "while()". We should not make
"until()" mean that.

Postfix "until ()" being legal is not a bug, but a perfectly regular
application of the postfix "until EXPR" syntax.

This ticket should be closed.

-zefram

@p5pRT p5pRT closed this as completed Jan 22, 2018
@p5pRT
Copy link
Author

p5pRT commented Jan 22, 2018

@iabyn - Status changed from 'open' to 'rejected'

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