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

Re: Package:: still ambiguous

Thread Previous | Thread Next
From:
Zefram
Date:
September 13, 2011 09:18
Subject:
Re: Package:: still ambiguous
Message ID:
20110913161834.GM18211@lake.fysh.org
Rafael Garcia-Suarez wrote:
>So, if I understand that last paragraph, that implies new syntax ?

Depends what you count as new syntax.  Certainly some new semantics,
including new builtin functions, but we don't need to add to perly.y.
I imagine something like

	$pkg = package_metaobject("Foo::Bar");
	# or: $pkg = new_anon_package();

	$obj = $pkg->new();   # unambiguously call class method
	$obj = bless({}, $pkg);   # only way to bless into anon package

	$pkg = ref_metaobject($obj);   # only for blessed objects

	use strict_packages;
	$obj = Foo::Bar->new();   # error

Obvious sources of trouble:

	$pkg = package_metaobject("Foo::Bar");
	bless($pkg, "Heh::Heh");
	$obj = $pkg->new;   # Foo::Bar->new or Heh::Heh->new?

	sub new {
		# current idiom, breaks if $_[0] is a package metaobject
		my $class = ref($_[0]) || $_[0];
	}

	$pkg = new_anon_package();
	$obj = bless({}, $pkg);
	$class = ref($pkg);   # surprising metaobject or useless string?

So we need some non-trivial thought about how the semantics will fit
together.  I'm determined that we won't get the kind of ill-thought-out
mess we've so often had before.

-zefram

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