TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote:

Ohh, conceptually we should split the 'r' and 'w' in 'rw'.
The r part is for the value going in. The w part is conceptually
part of the *return* type of the function. The convenience for the
caller lies in the fact that she doesn't have to extract the values
of interest from the returned Capture. The syntactic problem I'm
trying to point out is that the return type and parameter type in
a rw signature entry share the same slot.

You want a way to declare the function to accept both lvalue and non-lvalue items, and determine at run-time whether it can write back to it.

The MMD matching solution does not require return type matching. The information "does this conform" is part of the parameter types.

  multi sub foo (Num $x is ro) { ... }
  multi sub foo (Num $x is rw) { ... }

The second is not a candidate if you pass a literal, a constant, whatever. The second is considered a better match when it is a candidate by virtue of the ordering rules.


Reply via email to