develooper Front page | perl.perl5.porters | Postings from November 2011

Re: RFC: Autoloading charnames

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
November 23, 2011 07:31
Subject:
Re: RFC: Autoloading charnames
Message ID:
20111123153117.GD6369@tozt.net
On Wed, Nov 23, 2011 at 04:26:32PM +0100, Abigail wrote:
> On Wed, Nov 23, 2011 at 07:39:05AM -0600, Jesse Luehrs wrote:
> > On Wed, Nov 23, 2011 at 01:17:20PM +0100, Johan Vromans wrote:
> > > Jesse Luehrs <doy@tozt.net> writes:
> > > 
> > > > I don't see why using a \N{} sequence should have any impact on what
> > > > functions are available to use in my code.
> > > 
> > > Compare:
> > > 
> > >  $ perl -wE 'binmode STDOUT; warn File::Spec->catfile("foo","bar")'
> > >  Can't locate object method "catfile" via package "File::Spec" (perhaps you forgot to load "File::Spec"?) at -e line 1.
> > > 
> > > with:
> > > 
> > >  $ perl -wE 'STDOUT->binmode; warn File::Spec->catfile("foo","bar")'
> > >  foo/bar at -e line 1.
> > 
> > Sure, I think that's confusing too.
> 
> 
> I don't, and I really wish Perl did it more often. Every time I write
> 
>     Some::Class::I::did::not::use -> foo ()
> 
> and Perl tells me "oh, you didn't load Some::Class::I::did::not::use", 
> I think "well, if you know what's missing, why don't you just do it 
> for me". [1]
> 
> But maybe I'm the only Perl user who appreciates DWIM.

Well, loading a package can have arbitrary effects, so that's not
necessarily a safe thing to do (in case it actually was a typo). If it's
really what you want though, Class::Autouse is available on CPAN.

-doy

Thread Previous | 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