Skip Menu |

This queue is for tickets about the Promises CPAN distribution.

Report information
The Basics
Id: 81278
Status: resolved
Priority: 0/
Queue: Promises

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: status method leads to ugly code
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)
Subject: Re: [rt.cpan.org #81278] status method leads to ugly code
Date: Mon, 19 Nov 2012 09:07:26 -0500
To: bug-Promises [...] rt.cpan.org
From: Stevan Little <stevan.little [...] iinteractive.com>
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)
A number of predicates have been added and documented, thanks for this suggestion. The code is currently on github (https://github.com/stevan/promises-perl) but will be released to CPAN as 0.02 shortly.