develooper Front page | perl.perl5.porters | Postings from February 2009

[perl #63220] for and foreach not entirely synonymous

Thread Next
From:
Ben Tilly
Date:
February 13, 2009 16:53
Subject:
[perl #63220] for and foreach not entirely synonymous
Message ID:
rt-3.6.HEAD-12283-1234554770-299.63220-75-0@perl.org
# New Ticket Created by  Ben Tilly 
# Please include the string:  [perl #63220]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=63220 >


This is a bug report for perl from btilly@gmail.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.


-----------------------------------------------------------------
[Please enter your report here]

Both for and foreach are supposed to be synonyms.  But there is a small
difference - you can use foreach as an attribute but not for.  So

    use Attribute::Handlers;
    sub for :ATTR {
        print "Just another Perl hacker,\n";
    }
    sub foo :for {}
    foo();

is a syntax error while

    use Attribute::Handlers;
    sub foreach :ATTR {
        print "Just another Perl hacker,\n";
    }
    sub foo :foreach {}
    foo();

prints the usual message.

(This came up at http://www.perlmonks.org/?node_id=743657)

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.8:

Configured by _www at Sun Jan 13 20:34:01 PST 2008.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=darwin, osvers=9.0, archname=darwin-thread-multi-2level
    uname='darwin b70.apple.com 9.0 darwin kernel version 9.0.0: mon
dec 3 11:36:03 pst 2007; root:xnu-1228.0.1~4release_i386 i386 '
    config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe
-Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-arch i386 -arch ppc -g -pipe -fno-common
-DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing
-Wdeclaration-after-statement -I/usr/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement
-I/usr/local/include'
    ccversion='', gccversion='4.0.1 (Apple Inc. build 5465)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc -mmacosx-version-min=10.5.1', ldflags ='-arch i386 -arch
ppc -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-arch i386 -arch ppc -bundle -undefined
dynamic_lookup -L/usr/local/lib'

Locally applied patches:
    fix for regcomp CVE-2007-5116 security vulnerability

---
@INC for perl v5.8.8:
    /System/Library/Perl/5.8.8/darwin-thread-multi-2level
    /System/Library/Perl/5.8.8
    /Library/Perl/5.8.8/darwin-thread-multi-2level
    /Library/Perl/5.8.8
    /Library/Perl
    /Network/Library/Perl/5.8.8/darwin-thread-multi-2level
    /Network/Library/Perl/5.8.8
    /Network/Library/Perl
    /System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.8.8
    /Library/Perl/5.8.6
    /Library/Perl/5.8.1
    .

---
Environment for perl v5.8.8:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/btilly
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About