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