Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80458 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80398 invoked from network); 14 Jan 2015 11:37:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2015 11:37:22 -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.44 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.218.44 mail-oi0-f44.google.com Received: from [209.85.218.44] ([209.85.218.44:35176] helo=mail-oi0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/93-61073-1F456B45 for ; Wed, 14 Jan 2015 06:37:21 -0500 Received: by mail-oi0-f44.google.com with SMTP id a141so6891330oig.3 for ; Wed, 14 Jan 2015 03:37:18 -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=F0HLBh+ZUsVbUkSjxQaU+T50vxRX6P8iLzzHBMWopBI=; b=Ukjita6YKEbaayZ2hlhqMX2FnuyFdSpEuK8mbTDINdOab03vbpBd4kinTqbOpoM4+G Y7myHXlkvCC5Q2M1uga/wSbswMr/nSBYVQjN4Efgz8PjcPsqcAolWCMzRejhSItFRb9c O75QJhALdjj6QXKuIEatqeLLbq0xvaoT0pJfc= 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=F0HLBh+ZUsVbUkSjxQaU+T50vxRX6P8iLzzHBMWopBI=; b=SjIP9/QWRCISPqEPQxXWClTyPXY1vA57WG0U3M8zOG42q5YYlYQ0o3JtpJGrKNRo52 7GNWofAyY2g9E9S7hzCzqL3dxQapwZfLEfPaRbUs1BkR9YNYRoTJsO3LYxt7dkKfS6hn YqVWP2NxKEZD7/AQ/xKLCxlpgvbFgeh2FkfXAuXw6PNVFWG3PEBmx07KnDXKFeAGFI4o pcko6sqikU1rg3tiBQBCgN9cQ5+jkDxyE809aBZU2ZzgeZ2zV7URgH6WR0zEC8wHbr72 X4zXN0sv7DWrdOkNG4cSvBCMW5X/cbv1DCpXTE0azbPOk7IgSzD41EpGNYFjq4XtWEC7 4DoA== X-Gm-Message-State: ALoCoQmBz8G1l3jrpSh0VqCu4DVmbvSJH4OgIBkHlno8GsALkeg1SuL0FkJg4siRLKNFQnxaDNhz MIME-Version: 1.0 X-Received: by 10.60.76.138 with SMTP id k10mr2114965oew.86.1421235438763; Wed, 14 Jan 2015 03:37:18 -0800 (PST) Received: by 10.202.214.146 with HTTP; Wed, 14 Jan 2015 03:37:18 -0800 (PST) In-Reply-To: <1337AC4E-7705-4A5E-8CBB-8BBB0A18BB9D@ajf.me> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <76F9DAD3-5A22-4A53-8262-CF6B33D80FC3@ajf.me> <1337AC4E-7705-4A5E-8CBB-8BBB0A18BB9D@ajf.me> Date: Wed, 14 Jan 2015 13:37:18 +0200 Message-ID: To: Andrea Faulds Cc: Julien Pauli , PHP Internals List Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: narf@devilix.net (Andrey Andreev) Hi again, On Wed, Jan 14, 2015 at 1:21 PM, Andrea Faulds wrote: > Hi Andrey, > >> On 14 Jan 2015, at 11:10, Andrey Andreev wrote: >> >> I don't understand why it should be a bad thing that the API author >> forces rules on the consumer. The opposite is IMO fundamental to the >> concept of an API - the rules specified by the author are a contract >> that the consumer agrees to, and which allows for the whole thing to >> work properly. >> >> In this form, I don't get any benefit from strict type checks, because >> I only want them so that writing foo(int $bar) guarantees me that the >> caller *passed* an integer. Instead, I'd have to NOT use a type hint, >> and instead do an is_int($bar) check inside ... this beats the whole >> purpose. > > Why? What is wrong with a caller choosing to use weak type hints? Either way you receive an integer. Because it's pointless. Why would I want strict checks if I only cared for getting an integer? The whole point is that I care for what the caller passed, that I want specifically a check instead of a cast. Cheers, Andrey.