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

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

Thread Next
From:
Father Chrysostomos via RT
Date:
August 12, 2012 12:11
Subject:
[perl #114460] RFE: class as conditional self-defining keyword for package
Message ID:
rt-3.6.HEAD-11172-1344798677-1156.114460-15-0@perl.org
On Sun Aug 12 10:08:53 2012, LAWalsh wrote:
> 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
> 
> i.e.:
> 
>     class	<pkgname>;
> 
> would be  equivalent to:
> 
>     package <pkgname>;
> 		$::INC{'pkgname.pm'}= __FILE__ unless $::INC{'pkgname.pm'};
> 
> This provides the notational convenience of allowing class
> definition without playing with perl internals, (i.e.
>   "$::INC{pkg2filename(<pkgname>)}" )

%INC is not internal any more than $! is.  While adding such a keyword
would be harmless, I see little benefit.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114460

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