Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78163 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53121 invoked from network); 20 Oct 2014 23:27:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Oct 2014 23:27:50 -0000 Authentication-Results: pb1.pair.com header.from=lars@strojny.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lars@strojny.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain strojny.net from 46.4.40.248 cause and error) X-PHP-List-Original-Sender: lars@strojny.net X-Host-Fingerprint: 46.4.40.248 milch.schokokeks.org Received: from [46.4.40.248] ([46.4.40.248:37858] helo=milch.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/B1-42514-47A95445 for ; Mon, 20 Oct 2014 19:27:49 -0400 Received: from [IPv6:2001:a60:2526:4b01:dc87:2fe8:7e6b:e42c] ([2001:a60:2526:4b01:dc87:2fe8:7e6b:e42c]) (AUTH: PLAIN lars@schokokeks.org, TLS: TLSv1/SSLv3,256bits,ECDHE-RSA-AES256-SHA) by milch.schokokeks.org with ESMTPSA; Tue, 21 Oct 2014 01:27:44 +0200 id 0000000000000014.0000000054459A70.0000660B Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> Date: Tue, 21 Oct 2014 01:27:43 +0200 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <9BB32AF2-E776-46CA-8604-0B5283B5050C@strojny.net> References: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> To: Andrea Faulds X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Safe Casting Functions From: lars@strojny.net (Lars Strojny) Hi Andrea, > On 21 Oct 2014, at 00:57, Andrea Faulds wrote: >=20 > Good evening, >=20 > I am presenting a new RFC to add a set of three functions to do = validated casts for scalar types: >=20 > https://wiki.php.net/rfc/safe_cast >=20 > Please read it. I like the proposal except for one thing: the functions returning false = in case of an error. As the next logical function would be "to_bool()", = I foresee a lot of trouble with regards to API design as returning false = there either means successful cast to false or an error while casting. = What about changing the functions to take an $isError variable as a = second argument? $value =3D to_string(1.2, $isError); if ($isError) { ... } Alternatively one could do the same thing with an $isSuccess variable: $value =3D to_string(1.2, $isSuccess); if (!$isSuccess) { ... } Thoughts? cu, Lars