Skip Menu |

This queue is for tickets about the IO-Prompter CPAN distribution.

Report information
The Basics
Id: 127957
Status: resolved
Priority: 0/
Queue: IO-Prompter

People
Owner: Nobody in particular
Requestors: MIROD [...] cpan.org
Cc:
AdminCc:

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



Subject: A response of 0, or empty string, is considered true
It may be worth mentioning prominently in the docs that the value returned is a Contextual::Return::Value This means that when the response is a 0, or empty, it is considered true, which is a bit surprising. Try this: perl -MIO::Prompter -E'my $res= prompt( "dare type 0 (or just return) " ); say "res: [$res]"; say $res == 0 ? "look, res == 0" : "nope, res doe not == 0"; say $res eq "0" ? "look, res eq 0" : "nope, res doe not equal 0"; say $res ? "holy cannoli, res is true!" : "thank \$deity res is false"; ' __ mirod
Subject: Re: [rt.cpan.org #127957] A response of 0, or empty string, is considered true
Date: Fri, 7 Dec 2018 20:00:28 +0000
To: bug-IO-Prompter [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Merci beaucoup, Michel! I had thought that mentioning the object return value in the first and fifth paragraphs of the initial DESCRIPTION was sufficient, but reading it again, I see that it really isn't. So thank-you for pointing that out to me. I have now added a CAVEAT section immediately after the synopsis which (I hope!) more clearly warns of the problem you encountered. Please accept my apologies for this counter-intuitive edge-case in the module's interface. All the very best, Damian
Subject: Re: [rt.cpan.org #127957] A response of 0, or empty string, is considered true
Date: Sat, 8 Dec 2018 07:01:20 +0100
To: bug-IO-Prompter [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
Sacrebleu! I see it now: "returns an object representing that text" and "In scalar boolean contexts this return object evaluates true if the input operation succeeded.". I think what threw me off is that the description has more explanations about list context, so the bit about the thruthiness of the object got lost. Plus since the object behaves mostly like a regular scalar, I completely forgot it wasn't (if I ever realized it wasn't, I am not sure now), and focused on getting my menus right. So thanks for adding the caveat, hopefully it will help the next doc-skimmer like me. -- Michel On 07/12/2018 21:01, damian@conway.org via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=127957 > > > Merci beaucoup, Michel! > > I had thought that mentioning the object return value in the first and > fifth paragraphs > of the initial DESCRIPTION was sufficient, but reading it again, I see that > it really > isn't. So thank-you for pointing that out to me. > > I have now added a CAVEAT section immediately after the synopsis which (I > hope!) > more clearly warns of the problem you encountered. > > Please accept my apologies for this counter-intuitive edge-case in the > module's interface. > > All the very best, > > Damian >