develooper Front page | perl.perl5.porters | Postings from August 2012

[perl #114460] RFE: class as conditional self-defining keyword for package

Thread Previous | Thread Next
Linda Walsh
August 12, 2012 10:09
[perl #114460] RFE: class as conditional self-defining keyword for package
Message ID:
# New Ticket Created by  Linda Walsh 
# Please include the string:  [perl #114460]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.39 running under perl 5.14.2.

[Please describe your issue here]

Admittedly this might be doable in a CPAN module, but having it
builtin to the language would seem to clarify and simplify the
border between classes and packages, and the fear of 'use <pkgname>'
trying to use 'auto-semantics' to determine if it should look for 
pkgname in the LIB list.

This has likely already been thought of in some related form, but I'm
not aware of it being part of the language.

'class' <classname> will be equivalent to 'package' <pkgname>, 
with the exception that, UNLESS there has been a *previous*
'use' <classname> (thus it is loaded); it will define the package the
same as a 'package' statement would, *AND* set the values in the $::INC{}
hash to indicate that it should now be considered loaded into memory


    class	<pkgname>;

would be  equivalent to:

    package <pkgname>;
		$::INC{''}= __FILE__ unless $::INC{''};

This provides the notational convenience of allowing class
definition without playing with perl internals, (i.e. 
  "$::INC{pkg2filename(<pkgname>)}" ), which, IMO, is a good way to
allow same-file definitions of 'pure' classes that have no external
package (or 'package' baggage -- the requirements of 'package')
without the use or knowledge of Perl-Arcana**. 

As a lower case bareword, it shouldn't conflict with existing programs 
unless they have over-ridden warnings about such.

Might this, perhaps, not be a clean solution for not requiring changes
to 'use' that would have it 'guess' if a package is loaded or not?

**Perl-Arcana - knowledge of perl internals and invocations to achive
                results similar to other languages that require no 
								'internals-specific' knowledge to use in those other
								languages (Syntax/Semantic keyword differences not 

[Please do not change anything below this line]
This perlbug was built using Perl 5.14.2 - Wed Feb  8 15:59:25 UTC 2012
It is being executed now by  Perl 5.14.2 - Wed Feb  8 15:55:36 UTC 2012.

Site configuration information for perl 5.14.2:

Configured by abuild at Wed Feb  8 15:55:36 UTC 2012.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
    osname=linux, osvers=3.1.0-1.2-default, archname=x86_64-linux-thread-multi
    uname='linux build09 3.1.0-1.2-default #1 smp thu nov 3 14:45:45 utc 2011 (187dde0) x86_64 x86_64 x86_64 gnulinux '
    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Dd_dbm_open -Duseshrplib=true -Doptimize=-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe -Accflags=-DPERL_USE_SAFE_PUTENV -Dotherlibdirs=/usr/lib/perl5/site_perl'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.6.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 =' -L/usr/local/lib64 -fstack-protector'
    libpth=/lib64 /usr/lib64 /usr/local/lib64
    libs=-lm -ldl -lcrypt -lpthread
    perllibs=-lm -ldl -lcrypt -lpthread
    libc=/lib64/, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.14.2/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64 -fstack-protector'

Locally applied patches:

@INC for perl 5.14.2:

Environment for perl 5.14.2:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About