Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78214 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77879 invoked from network); 21 Oct 2014 22:51:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Oct 2014 22:51:19 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.208 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.208 imap2-3.ox.privateemail.com Received: from [192.64.116.208] ([192.64.116.208:50391] helo=imap2-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/0D-02077-663E6445 for ; Tue, 21 Oct 2014 18:51:19 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 2B5548C0080; Tue, 21 Oct 2014 18:51:16 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id npSJrRhyE8au; Tue, 21 Oct 2014 18:51:16 -0400 (EDT) Received: from oa-edu-169-138.wireless.abdn.ac.uk (oa-edu-169-138.wireless.abdn.ac.uk [137.50.169.138]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id B576C8C007B; Tue, 21 Oct 2014 18:51:13 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: Date: Tue, 21 Oct 2014 23:51:11 +0100 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <866A39C7-6F11-408D-8BCA-594BA22E8569@ajf.me> References: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> To: Dmitry Stogov X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Safe Casting Functions From: ajf@ajf.me (Andrea Faulds) > On 21 Oct 2014, at 10:14, Dmitry Stogov wrote: >=20 > some notes: > - it's probably make sense to implement these function as a new = opcode(s) in VM That could be an optimisation later, yes. I note that you=E2=80=99ve = added function replacement with opcodes for certain commonly-used = functions. We could make these functions use that. Then they=E2=80=99d = still be usable as callbacks. > - in case of conversion failure it's better to throw exception = (to_int() returning FALSE is a pain). I am gradually warming to throwing an exception. An interesting idea = I=E2=80=99ve had suggested on Twitter was by Matt Parker, who suggested = that I add an optional 2nd argument. Without the argument, it throws an = exception. With an argument, it returns that value (as a default) = instead of throwing an exception. -- Andrea Faulds http://ajf.me/