On Wed, Nov 23, 2011 at 07:51:59AM -0700, Karl Williamson wrote: > On 11/23/2011 06:39 AM, 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. > > > >-doy > > > > 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. > > Does this fact change anyone's opinion? Well, this is just how the rest of perl works: $ perl -E'warn File::Spec->catfile("foo", "bar"); package foo { use File::Spec () }' foo/bar at -e line 1. since packages are global and use happens at compile time. The only thing that is confusing to me is for this kind of thing to happen for autoloaded stuff (when it's not necessary anyway - I'm not really proposing for IO::File to stop using File::Spec). I feel like within a given module, either use of anything in it should trigger autoloading, or none of it should (and what "anything" means in this case depends on whether charnames stays as one module or is split into charnames (for the functions) and charnames::guts or whatever (for the \N{} stuff)). I'll admit that this may be a bit overcomplicated on the implementation side. -doyThread Previous | Thread Next