develooper Front page | perl.perl5.porters | Postings from August 2009

Re: A complete design for := (bind)

Thread Previous | Thread Next
August 21, 2009 04:56
Re: A complete design for := (bind)
Message ID:
Chip Salzenberg wrote:
>Fortunately, the Signature syntax C<:LIST> gives us an out.  Inside a
>Signature -- whether a function declaration or C<:LIST> -- we can adopt the
>Perl 6 default of no-flatten and use the splat as a flatten marker.

Pretty nifty.  Could C<:LIST> be the constructor for a first-class object,
that we can pass around and use on the LHS of C<:=>?  As in,

	my($a, @b);
	my $sig = :($a, @b);
	$sig := \(@c);

In this system, the LHS of := doesn't have to have signature syntax,
it just has to be an expression that evaluates to (a reference to)
a signature object.

>expects three things on the RHS: a scalar (somehow), an array (somehow), and
>a hash (somehow).  In contrast,
>expects only scalars (somehow) on the RHS.

The examples that you show later actually seek scalar/array/hash
*references* on the RHS.

>   Side point: An unidentified variable inside a C<:LIST> could be
>   automatically declared.

No thanks.  We should precede C<:LIST> with C<my> or C<our> to achieve

For parameter list destructuring, I guess we're going to map

	sub foo ($x, @y, *@z) { ... }


	sub foo { my :($x, @y, *@z) = \(@_); ... }

or possibly some variation on this for readonlyness.

Regarding readonlyness, I'd like parameter aliases to be readonly by
default, but I also think that there should be a simple correspondence
between the parameter list syntax and the standard signature syntax.
So it ought to be possible to write a non-parameter signature in such
a way that it gets readonlyness by default, overridable per item.
Either readonly should always be the default, or there should be some
flag in the signature syntax to control the default.


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