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

Re: Package:: still ambiguous

Thread Previous | Thread Next
Rafael Garcia-Suarez
September 14, 2011 06:59
Re: Package:: still ambiguous
Message ID:
On 14 September 2011 14:55, Zefram <> wrote:
> 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)'
> 123

I stand corrected.

>>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.

Yes : to avoid ambiguity I wrote "first-class feature" instead of
"first-class object". Indeed a new svtype sounds right for this.
The ambiguity here is fed by the syntax : $pkg->new looks like a
regular method call, but it's a a class method call.
Since you propose a new first-class object why not new syntax ? A new
sigil maybe ? (but it will be hard to shove a new sigil in the current

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