TSa wrote:
>  The use of £ in
>   sub foo (£ pointlike ::PointType $p1, PointType $p2 --> PointType)
>  is that of *structural* subtyping. Here FoxPoint is found to be
>  pointlike. In that I would propose again to take the 'like' operator
>  from JavaScript 2. Doing that the role should be better named Point
>  and foo reads:
>   sub foo (like Point ::PointType $p1, PointType $p2 --> PointType)
>  This is very useful to interface between typed and untyped code.
>  With the 'like' the role Point has to be *nominally* available
>  in the argument. There's no problem with 'like'-types being more
>  expensive than a nominal check.

Ah; that clears things up considerably.  If I understand you
correctly, John is using '£' to mean "use Duck Typing here".  _That_,
I can definitely see uses for.  As well, spelling it as 'like' instead
of '£' is _much_ more readable.  With this in mind, the above
signature reads as "$p1 must be like a Point, but it needn't actually
be a Point.  Both $p2 and the return value must be the same type of
thing that $p1 is."

What, if anything, is the significance of the fact that pointlike (in
John's example; 'Point' in TSa's counterexample) is generic?

Jonathan "Dataweaver" Lang

Reply via email to