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

Re: Package:: still ambiguous

Thread Previous | Thread Next
September 14, 2011 05:55
Re: Package:: still ambiguous
Message ID:
Rafael Garcia-Suarez wrote:
>>        $obj = $pkg->new();   # unambiguously call class method
>That works with $pkg being a string, right now.

No, that's how I started this thread.  If $pkg is, say, the string
"Foo::Bar", then it is ambiguous between the package Foo::Bar and the
I/O handle *Foo::Bar{IO}.  The I/O handle meaning takes precedence,
if there is a handle of that name.

$ perl -E 'package Foo::Bar { sub say { say "Foo::Bar::say(@_)" } } open(\*Foo::Bar, ">&STDOUT"); $pkg = "Foo::Bar"; $pkg->say(123)' 

>I would prefer avoiding thinking about $pkg as a special kind of

You're thinking of "object" in the OO sense.  I meant it in the looser
sense, of anything that the language can manipulate by first-class
mechanisms.  It's an object in the same sense in which an (unblessed)
array is an object.  We could well call it merely a "package".  It would
probably end up implemented as an svtype, SVt_PVPK.


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