Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dereference and assignment semantics.

0 views
Skip to first unread message

Audrey Tang

unread,
Jan 3, 2006, 4:22:55 PM1/3/06
to perl6-c...@perl.org
This is a brain-dump of how container types and contexts work in the
new Pugs runcore.

Assuming everything other than an explicit method call is subject to
MMD, we have this desugaring:

# Sugared syntax
${$x} = 5;

# Desugared syntax
&infix:<=>(&circumfix:<${ }>($x), 5);

It's straightforward to type the relevant &infix:<=> part, given that
::Scalar, ::Array and ::Hash are roles that "does" the ::Ref role.

proto infix:<=> ((Ref of ::v) ::a is rw, ::v) --> ::a;
multi infix:<=> ((Scalar of ::v) ::a is rw, ::v) --> ::a {...}

However, what should the type of &circumfix:<${ }> be?

I'm currently going with:

proto circumfix:<${ }> (Any) --> (Scalar of Any) is rw;
multi circumfix:<${ }> ((Scalar of Any) ::a) --> ::a is rw {...}

That is, it applies to an argument that can yield a Scalar object when
used as a rvalue.

Below I'll use the notation value($x) to mean $x evaluated as an
rvalue, analogous to
the variable($x) special form for marking explicit lvalues.

Here is the signature for for prefix:<\>:

proto prefix:<\> (Any) --> (Ref of Any);
multi prefix:<\> (Ref ::T is rw) --> ::T {...}
multi prefix:<\> (::T) --> (Scalar of ::T) {...}

So these two are legal:

${ \3 }; # value(&prefix:<\>(3)) yields a
::Scalar container object
${ \$x }; # value(&prefix:<\>($x)) is just variable($x)

But these are not:

${ \3, }; # value(&prefix:<\>(&infix:<,>(3)))
yields a ::Tuple, not ::Scalar
${ variable($x) }; # value(variable($x)) means the same as value($x)

Thanks,
Audrey

0 new messages