Re: Getting rid of want()
Moritz Lenz wrote: > Instead we should provide a very DWIMmy way to (lazily) create objects > that behave differently in different contexts. That's precisely what the Contextual::Return module does for Perl 5. It's less than perfect in Perl 5, because it has to be implemented via runtime trickery, and hence is too slow. But that problem will disappear in Perl 6 (and perhaps eventually in Perl 5 too) as I'll be able to use macros to remove the runtime overheads. > Patrick pointed out that it can currently be done with > > return $value but role { method Bool { > $code_for_boolean_context_here } }; This is essentially what Contextual::Return does, only with a dwimmier syntax. > And if you propose to keep want(), how would you think it could work? The only thing C::R doesn't handle that want() does is determining the arity of a list context (i.e. how many elements are expected back). That information can be very handy for optimization. And, yes, C::R would already handle it if I could think of a clean interface that was implementable in Perl 5 without source filters. Damian
Re: Getting rid of want()
Brandon S. Allbery KF8NH wrote: > On 2009 Mar 31, at 17:04, Moritz Lenz wrote: >> 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. > > Hm, I was under the impression that want() had already been dropped, > and subs return captures. S06 still has a chapter =head2 The C function Cheers, Moritz
Re: Getting rid of want()
On 2009 Mar 31, at 17:04, Moritz Lenz wrote: 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. Hm, I was under the impression that want() had already been dropped, and subs return captures. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part
Getting rid of want()
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 others). What do you think? And if you propose to keep want(), how would you think it could work? Cheers, Moritz