TSa wrote:
Jonathan Lang wrote:
> Please, no attempts to merge signatures.  Instead, use multiple
> dispatch

That avoids the problem before it occurs. But do you expect
every role to provide its methods as multi just in case?

Conceded.

Bear in mind, though, that signatures include not only type
information, but also parameter names; and method calls are permitted
to pass an argument into a given parameter by means of its name
instead of its position, so the names cannot be disregarded.  For
instance, consider the following pair of methods, supplied by
different roles:

  method connect ( Terminal $from, Terminal $to ) { doit($from, $to) }
  method connect ( Terminal $dest, Terminal $src ) { doit($src, $dest) }

There's no automated means that would allow you to reliably merge
those two signatures in a semantically appropriate way - not until
perl is smart enough to know that "from" and "src" have similar
connotations.  When you have a conflict like this, you're better off
dropping the signatures altogether and leaving it up to the guy
writing the new implementation to figure out what to do with the
arguments that he gets.

--
Jonathan "Dataweaver" Lang

Reply via email to