To quote Jonathan Worthington:
do not want().

We had a discussion on #perl6 tonight about how to implement want(), and
 basically came to no conclusion. Then I came up with the idea that any
lazy implementor will come up with: drop it from the language.

The reason is that it seems impossible to come up with a way to
determine context information efficiently.
Consider the code 1+a(). One would expect want() in the body of a to
return something like Num, right? But how could it get to that
conclusion? After all there's a sub infix:<+>(Any $a, Any $b) defined
(that will probably coerce to Num, but how the heck is the compiler
supposed to know that, in the general case, from user supplied
operators? after all we don't want to make "core" things special) that
doesn't look like Num at all.

Instead we should provide a very DWIMmy way to (lazily) create objects
that behave differently in different contexts.

Patrick pointed out that it can currently be done with

return $value but role { method Bool { $code_for_boolean_context_here } };

(which would be fine by me, but perhaps might not be pretty enough for

What do you think?
And if you propose to keep want(), how would you think it could work?


Reply via email to