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 08:32
Subject:
Re: RFC: Autoloading charnames
Message ID:
20111123163209.GF6369@tozt.net
On Wed, Nov 23, 2011 at 09:07:36AM -0700, Tom Christiansen wrote:
> Karl Williamson <public@khwilliamson.com> wrote
>    on Wed, 23 Nov 2011 07:51:59 MST: 
> 
> >>>> 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" (perh<SNIP>
> >>>
> >>> with:
> >>>
> >>>   $ perl -wE 'STDOUT->binmode; warn File::Spec->catfile("foo","bar")'
> >>>   foo/bar at -e line 1.
> 
> >> Sure, I think that's confusing too.
> 
> > FWIW, I find this confusing as well, yet this is how things work today:
> 
> > 	$ blead -E '
> > 	    print charnames::viacode(0x41), "\n";
> > 	    package foo {
> >      	    	use charnames();
> >           }'
> >
> > 	LATIN CAPITAL LETTER A
> 
> > Loading charnames in a different scope, even package, enables
> > use of the functions at a distance.
> 
> Ayup.
> 
> > Does this fact change anyone's opinion?
> 
> It may, but it doesn't change *mine*.  This is just how things happen 
> in Perl, and there's no way to address it without redesigning the whole
> language from the ground up; see Perl6.
> 
> And er, I've actually made intentional use of the sort of thing you show in
> the quoted portion.  Similarly with IO:: stuff.  It's probably a dumb thing
> to do, but I knew that was how Perl happens to work, so I did it.  It's a
> bit embarrassing but there it is.  You use what's there.
> 
> Perl really isn't spec-based to allow one to adjudge a bug from a feature
> based on a formal spec, so there's a lot of this sort of thing going around.

Right. And this is why I'd like to try to avoid adding more things like
this whenever possible - these are the sorts of things that makes the
language a lot harder to change in the future. Can we even make IO::File
stop loading File::Spec at this point? Someone may be relying on this
autoloading behavior, and their code would break. (To be clear, I think
the answer to this question is "yes", but the potential for breaking
existing code isn't something that should be ignored either.)

-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