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

parser bug: print not (1,2,3)[0] #912

Closed
p5pRT opened this issue Dec 3, 1999 · 3 comments
Closed

parser bug: print not (1,2,3)[0] #912

p5pRT opened this issue Dec 3, 1999 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 3, 1999

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

Searchable as RT1847$

@p5pRT
Copy link
Author

p5pRT commented Dec 3, 1999

From @andk

perl -e 'print not (1,2,3)[0];'
syntax error at -e line 1, near ")["
Execution of -e aborted due to compilation errors.

This was legal up to perl5.005_03.

I found this while trying to compile DBD​::XBase for devel releases.

Perl Info


Site configuration information for perl 5.00562:

Configured by k at Sun Oct 17 08:54:16 CEST 1999.

Summary of my perl5 (revision 5.0 version 5 subversion 62) configuration:
  Platform:
    osname=linux, osvers=2.2.12, archname=i586-linux
    uname='linux hohenstaufen.in-berlin.de 2.2.12 #2 smp sat oct 2 11:10:42 cest 1999 i586 unknown '
    config_args='-Dusemymalloc=y -Doptimize=-g -Dprefix=/usr/local/perl5.005_62-Oct17 -des'
    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.7.2.3
    cppflags='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -DDEBUGGING -I/usr/local/include'
    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 -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.0.7.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'

Locally applied patches:
    


@INC for perl 5.00562:
    /usr/local/perl5.005_62-Oct17/lib/5.00562/i586-linux
    /usr/local/perl5.005_62-Oct17/lib/5.00562
    /usr/local/perl5.005_62-Oct17/lib/site_perl/5.00562/i586-linux
    /usr/local/perl5.005_62-Oct17/lib/site_perl
    .


Environment for perl 5.00562:
    HOME=/home/k
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/k/bin:/usr/local/bin:/usr/bin:/bin:.:/usr/local/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/perl/bin
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 1999

From @gsar

On Fri, 03 Dec 1999 13​:05​:25 +0100, "Andreas J. Koenig" wrote​:

perl -e 'print not (1,2,3)[0];'
syntax error at -e line 1, near ")["
Execution of -e aborted due to compilation errors.

This was legal up to perl5.005_03.

I found this while trying to compile DBD​::XBase for devel releases.

I'm not sure how serious a compatibility issue this will be.
Opinions welcome.

Sarathy
gsar@​ActiveState.com

Inline Patch
-----------------------------------8<-----------------------------------
Change 4673 by gsar@auger on 1999/12/09 04:00:23

	document compatibility issue with literal list slices and NOTOP
	(C<not (1,2,3)[0]> is now a syntax error)

Affected files ...

... //depot/perl/pod/perldelta.pod#118 edit

Differences ...

==== //depot/perl/pod/perldelta.pod#118 (text) ====
Index: perl/pod/perldelta.pod
--- perl/pod/perldelta.pod.~1~	Wed Dec  8 20:00:28 1999
+++ perl/pod/perldelta.pod	Wed Dec  8 20:00:28 1999
@@ -125,6 +125,28 @@
 has been removed, because it could potentially result in memory
 leaks.
 
+=item Parenthesized not() behaves like a list operator
+
+The C<not> operator now falls under the "if it looks like a function,
+it behaves like a function" rule.
+
+As a result, the parenthesized form can be used with C<grep> and C<map>.
+The following construct used to be a syntax error before, but it works
+as expected now:
+
+    grep not($_), @things;
+
+On the other hand, using C<not> with a literal list slice may not
+work.  The following previously allowed construct:
+
+    print not (1,2,3)[0];
+
+needs to written with additional parentheses now:
+
+    print not((1,2,3)[0]);
+
+The behavior remains unaffected when C<not> is not followed by parentheses.
+
 =back
 
 =head2 C Source Incompatibilities
End of Patch.

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 1999

From @andk

On Wed, 08 Dec 1999 20​:04​:58 -0800, Gurusamy Sarathy <gsar@​ActiveState.com> said​:

On Fri, 03 Dec 1999 13​:05​:25 +0100, "Andreas J. Koenig" wrote​:

perl -e 'print not (1,2,3)[0];'
syntax error at -e line 1, near ")["
Execution of -e aborted due to compilation errors.

This was legal up to perl5.005_03.

I found this while trying to compile DBD​::XBase for devel releases.

I'm not sure how serious a compatibility issue this will be.
Opinions welcome.

I have compiled 100s of CPAN modules after that change and so it seems
that only DBD​::XBase uses "not" in such an idiom. I CC the author so
he can reduce the compatibility problem.

Sarathy
gsar@​ActiveState.com
-----------------------------------8<-----------------------------------
Change 4673 by gsar@​auger on 1999/12/09 04​:00​:23

document compatibility issue with literal list slices and NOTOP
\(C\<not \(1\,2\,3\)\[0\]> is now a syntax error\)

Affected files ...

... //depot/perl/pod/perldelta.pod#118 edit

Differences ...

==== //depot/perl/pod/perldelta.pod#118 (text) ====
Index​: perl/pod/perldelta.pod
--- perl/pod/perldelta.pod.1 Wed Dec 8 20​:00​:28 1999
+++ perl/pod/perldelta.pod Wed Dec 8 20​:00​:28 1999
@​@​ -125,6 +125,28 @​@​
has been removed, because it could potentially result in memory
leaks.

+=item Parenthesized not() behaves like a list operator
+
+The C<not> operator now falls under the "if it looks like a function,
+it behaves like a function" rule.
+
+As a result, the parenthesized form can be used with C<grep> and C<map>.
+The following construct used to be a syntax error before, but it works
+as expected now​:
+
+ grep not($_), @​things;
+
+On the other hand, using C<not> with a literal list slice may not
+work. The following previously allowed construct​:
+
+ print not (1,2,3)[0];
+
+needs to written with additional parentheses now​:
+
+ print not((1,2,3)[0]);
+
+The behavior remains unaffected when C<not> is not followed by parentheses.
+
=back

=head2 C Source Incompatibilities
End of Patch.

--
andreas

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