Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79055 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37957 invoked from network); 21 Nov 2014 00:46:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2014 00:46:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=adam@adamharvey.name; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=adam@adamharvey.name; sender-id=pass Received-SPF: pass (pb1.pair.com: domain adamharvey.name designates 209.85.223.178 as permitted sender) X-PHP-List-Original-Sender: adam@adamharvey.name X-Host-Fingerprint: 209.85.223.178 mail-ie0-f178.google.com Received: from [209.85.223.178] ([209.85.223.178:41260] helo=mail-ie0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/90-32541-75B8E645 for ; Thu, 20 Nov 2014 19:46:16 -0500 Received: by mail-ie0-f178.google.com with SMTP id tp5so3976563ieb.37 for ; Thu, 20 Nov 2014 16:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamharvey.name; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Sg4agBMDwOXJb+kZ9OChh+TFaoulS9+F8xvaRrRfUqE=; b=aWjzDqMHciKNJyJYZ8QYEvID5LMdaZvTFPME78EyEuyluQBAvB1kXPCYpzoYC9BDQ/ H0IhW2EM67mAzE2BNt3pYfNqiEEZlxoZzSNxkw5ApCXBvAUZrwgnxvtDdgrpewXYmUAd 5Rh4M4/GrDSGVoi6vA7l9CsRnTJPLIC8a4cic= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=Sg4agBMDwOXJb+kZ9OChh+TFaoulS9+F8xvaRrRfUqE=; b=idK5vNO9PFvIIKXdllszTTme04TTBmVP79TpynswdtI6nr/UPAf5RrTp3KN92V3eVe ZaHhaq84dz8AoszmBfLf3NCPVv/P7ZmSNo2hgvqcKIYAwQY7Ry7loD7HM14E16RTYpj4 nHfY4mDu1cVbrDMQtQblspH+SXf6/bwRW6S/RMMhf+RZ/hvJrGJrYKKOMYdE9Myjj6Xe pEAGM7+qbxR3P5JKf2ys3ImE/ligikcnoXOweMPkSdGQ3P88E/Oe6o/IBHB2oYBc0mUN htzEP+GxOI+2CTe9eD2ouxSAXjP631FEGLE0K9mtvAlPLQjcrrHPARTYNSTafcToACYE 0O0g== X-Gm-Message-State: ALoCoQkmBFi0XXN7fgUvydbzYhKfkyvWd/IX+jsqoXcPpQo+FMxlONd81qrdJMRBO2pvy5DQq0U3 X-Received: by 10.50.118.35 with SMTP id kj3mr12567779igb.30.1416530772683; Thu, 20 Nov 2014 16:46:12 -0800 (PST) MIME-Version: 1.0 Sender: adam@adamharvey.name Received: by 10.42.86.129 with HTTP; Thu, 20 Nov 2014 16:45:52 -0800 (PST) In-Reply-To: References: Date: Thu, 20 Nov 2014 16:45:52 -0800 X-Google-Sender-Auth: SNMpUPJ_F-S8GFkLTka7nCQze00 Message-ID: To: Levi Morrison Cc: Andrea Faulds , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [VOTE][RFC] Safe Casting Functions From: aharvey@php.net (Adam Harvey) My -1 is pretty much the same as Levi's: On 19 November 2014 13:57, Levi Morrison wrote: > - The RFC does not address how this is different from > FILTER_VALIDATE_* from ext/filter. I know there was a mention of this > on the mailing list, but the RFC should say why a tool that already > exists to solve this kind of problem is insufficient, especially when > it is enabled by default. I'm also somewhat concerned that these functions are conflating two concerns (validation and conversion). > - PHP suffers a lot from function bloat and this RFC provides > multiple functions that do the same thing but differ only in how they > handle errors. A simple validation of "can this be safely cast to an > integer without dataloss?" avoid the issue entirely and would be fewer > functions. +1: the idea of adding two sets of identical functions except for how they signal errors isn't one I like. Derick raised a good point elsethread: this is really tied into how we want to signal errors in PHP 7. If we switch to exceptions, then let's figure out a plan of attack and switch to exceptions everywhere, not just in the odd function here and there. If we don't, then the to_* functions shouldn't be added. > To summarize: I like the idea of having tools that helps us convert > between types in a lossless way, but I don't think this proposal is > what is best for PHP. -1 for me but I hope to see this revisited. I don't know that I'd ever be a strong +1 on this (adding more type conversion matrices to PHP doesn't seem like a good idea to me, whether it's in the language itself or in the standard library, and I feel like we have the validation part of this already in filter and ctype), but if we figured out the error handling situation and had only one set of functions, I could probably grit my teeth and abstain, at least. Adam