Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80641 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6091 invoked from network); 16 Jan 2015 13:00:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2015 13:00:46 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.218.41 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:45577] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/01-00273-C7B09B45 for ; Fri, 16 Jan 2015 08:00:45 -0500 Received: by mail-oi0-f41.google.com with SMTP id i138so17221386oig.0 for ; Fri, 16 Jan 2015 05:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Uh/502M7AComXr/mQqXQgJHwqRfkTtLi/skuLV9BPdM=; b=iaWkbprpyuCHMUIHrpG3KjHkRVXsBMDLAQE3Zy33ntiiljP9ZcyF5LP9haQvNQ3PUo H/AUftmGx89iVjfVBldSnpKG++GjDlfdAgPpcZ4MVrdzOlenNFgJTXFctrTn2Sx+wL0Z WIOGkXXF+ionp71ZtVFGW3Zj/ESuIK82x4xGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Uh/502M7AComXr/mQqXQgJHwqRfkTtLi/skuLV9BPdM=; b=KCYHk5xJ99ME/akhWawRPPtuShE5OM4FGgbVCpQaYqfLj7dpOzBjBnQyoAVBhgUwQ2 uWefY4Ss+vVmVBxQvN4sg4gZB58RUq/Uq4HWKSzP8W2a/TxF8KeBekgrUGNTzp21D9/D h+H+zA0wM7vGdfPPdNa/LVOGgnEHOwYZBcu6z4A2ALyBq4SC5q5stI7uvGfvW9BQlh7+ oembPx52k0hg5UzRLWVjt9/bgAKf5Un2t5t6FEQFnb8gGMZ2e9Noeb+yDEi5bAeiNFzo L1DRBMe2b4Fta8yeVXDUDUwQ8Y8qVEEF5qLilUqXuyC9h8GAID4bQ1JtsBIDBMTDzuOM HaEg== X-Gm-Message-State: ALoCoQk4fn9EbQnO2lcJ8x5cftc4mnRrO66alG8UPBRZp29CISlR1mWOG9BCHRVkwL9WyuL5bxyA MIME-Version: 1.0 X-Received: by 10.202.196.206 with SMTP id u197mr8791038oif.21.1421413241168; Fri, 16 Jan 2015 05:00:41 -0800 (PST) Received: by 10.202.214.146 with HTTP; Fri, 16 Jan 2015 05:00:41 -0800 (PST) In-Reply-To: <54B90431.10903@gmail.com> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <9a033dd1f223f854e760924d118ab812@mail.gmail.com> <2ae0164cb9b9bf1c974d7a3c60af0466@mail.gmail.com> <6105ea99002e634373c09685310e26a6@mail.gmail.com> <54B90431.10903@gmail.com> Date: Fri, 16 Jan 2015 15:00:41 +0200 Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: narf@devilix.net (Andrey Andreev) Hi, On Fri, Jan 16, 2015 at 2:29 PM, Rowan Collins wrote: > Mike Willbanks wrote on 15/01/2015 16:55: >> >> It also means that then a library developer would >> need to handle conditions on both sides (when in weak vs. strict). So I >> don't really understand where the gains of this would come from and it >> actually causes me concern in that what if a developer forgets to define >> strict and you're entire system is built on strict. > > > In case this hasn't been repeated enough times already: No They Would Not. > > As a library developer, you do not rely on strict or weak hints, you rely on > the variables you receive being of the types you require. This is guaranteed > in both modes. > > You cannot stop the user of your library doing whatever it takes to get past > your validation. It is up to them to provide sane inputs to your published > API, and no version of type hinting can change that. This is mostly true, but relying on the variable that you receive inside a function is different from relying on the variable that gets passed to a function. Yes, there will be users who will simply do an explicit cast, but there will also be users who will take notice of the produced error, and ask themselves why first, instead of immediately trying to "override" it. Many developers want to do that, regardless of the reasons why. Some just like the strict philosophy better, some see it as a way of educating their users, and others use it sparingly. Try arguing with anybody writing crypto code and they will all tell you that any case of uncertainty must be handled with a *hard* failure. You may not agree that it is necessary, but that doesn't make it invalid. And intentionally allowing only one guaranteed behavior does imply that the other is invalid. For the Nth time - if I want to achieve that effect, I will code for both cases by not using the feature and doing is_int(), is_string(), is_bool(), etc. checks, so the language might as well help me do it. I would understand if it was not helping with something that's just wrong, but this is not the case at all here. Cheers, Andrey.