Yeah, I was thinking the exact same thing. I think I will add some predicate methods to the Deferred object (and proxy them via the Promises object).
Thanks,
- Stevan
On Nov 19, 2012, at 8:56 AM, Toby Inkster via RT wrote:
Show quoted text> Mon Nov 19 08:56:47 2012: Request 81278 was acted upon.
> Transaction: Ticket created by TOBYINK
> Queue: Promises
> Subject: status method leads to ugly code
> Broken in: (no value)
> Severity: (no value)
> Owner: Nobody
> Requestors: mail@tobyinkster.co.uk
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=81278 >
>
>
> Ugly:
>
> if ($promise->status eq Promise::Deferred::IN_PROGRESS)
>
> Uglier:
>
> if ($promise->status eq "in progress")
>
> Better would be to move the constants into the Promise package:
>
> if ($promise->status eq Promise::IN_PROGRESS)
>
> Maybe add a little overload magic:
>
> if ($promise == Promise::IN_PROGRESS)
>
> Or just a plain method:
>
> if ($promise->is_in_progress)