Raphael Descamps wrote:
> I personally don't understand why we don't have a exclude and alias
> operator in Perl 6 but I have not read all the synopses and don't have
> an overview.

I don't think that it's explicitly spelled out anywhere; but the
reason is fairly straightforward: exclude and alias would break the
interface.

Take Stringy as an example: when a class says "does Stringy", it's
making certain promises about its syntax and semantics: e.g., it will
have a "method say", and "method say" should result in sending a
string of text to an output stream.  Thus, any routine that asks for
"Stringy $x" as one of its parameters should be able to put "$x.say"
in its code and get the expected results.

But if Foo does Stringy but excludes or aliases .say, a routine that
asks for a Stringy $x but receives a Foo $x will run into problems the
moment "$x.say" shows up in its code.  If .say was excluded, the
semantics are no longer available at all.  If it was aliased, the
semantics are still available under another name; but that does the
routine no good, because it has no idea what the new name is, or even
that it exists.  Either way, "$x.say" will not do what the routine
intended it to do.  The interface is broken.

--
Jonathan "Dataweaver" Lang

Reply via email to