On Tue, Mar 08, 2005 at 10:19:10AM +0100, Thomas Sandlaß wrote:
: >Or perhaps even
: >
: >sub foo (Num @in is copy does LinearInterpolation)
: >{
: >   ...
: >}
: 
: This is my big questionmark on roles: is the above a contraint
: or merely a directive. In the former case only Arrays of Num that
: do LinearInterpolation are allowed, in the latter case every
: Array of Num that is used as argument gets the role attached while
: it lingers in foo. I just realized there's a trait_auxiliary:shall
: mentioned in A12 which I've not seen in action somewhere. This could
: be the second meaning and roles in signatures describe what is *done*
: to the arguments not what they shall be able to do.

One can always mixin a "does LinearInterpolation" at run time in the
body of the sub to get the effect of a directive, so I think the most
useful thing is to treat roles in signatures as constraints where
they can be used to select for MMD.

That being said, it probably depends on the role.  A variable that is
intended to be bound to another value presents a view of that other
value that may differ from that actual value in significant ways.
We probably need to come up with a way to mark such instructions to
the container that aren't intended to add constraints.

And we probably need to distinguish view directives from ordinary
mixins anyway, since if you apply a "does LinearInterpolation" as
an ordinary mixin, the object itself is reblessed into an anonymous
class that includes the role, and that effect would persist beyond the
function call.  Whereas a view directive would only be in operation
during the call.  Maybe we need to work in the linguistic notion of
"pretends to be" somehow.

: I still wonder how the type system really works...

Me too.  If it's any comfort, just think of the design of Perl 6 as
a genetic algorithm running on a set of distributed wetware CPUs.
We'll just keep mutating our ideas till they prove themselves adaptive.

Larry

Reply via email to