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

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

Thread Next
Father Chrysostomos via RT
August 12, 2012 12:11
[perl #114460] RFE: class as conditional self-defining keyword for package
Message ID:
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{''}= __FILE__ unless $::INC{''};
> 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

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