Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80564 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18372 invoked from network); 15 Jan 2015 16:11:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2015 16:11:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:47565] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/C2-14306-796E7B45 for ; Thu, 15 Jan 2015 11:11:04 -0500 Received: by mail-ob0-f180.google.com with SMTP id wp18so9928611obc.11 for ; Thu, 15 Jan 2015 08:11:00 -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:content-transfer-encoding; bh=WO7NRVhVyDGUq3xU4g9RM2S92sDAGqdFs4mcyNGonxc=; b=dhPO+2wht8gGClMw4afZ/+7TK65/6lpa4Bz/z24d2VDeL3AHQVddgYlkcCNbum4Zjd Hf08dZlxpySA4s28o3V5rUvd7b5klllskOGrRs8VvRqnazgXNXvu+r8j+3qEL0vDJC3o f9T7hXgrsk+11dn9EU7qR7RoG7o0Aqt3zcbxk= 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 :content-transfer-encoding; bh=WO7NRVhVyDGUq3xU4g9RM2S92sDAGqdFs4mcyNGonxc=; b=iw6hSrls48TdlvtfZ2ZuE4GwY1hJM44sOCoXZFRspNHDdQc3A/frR/Ev7bVayCSDlp f2MwLPBCqPP4vOrC7/c2FOr0wJ6Ti26sh73aCmk/OgajJ7aWTAceC/bWO2ghaBVvFj0D 5kAcCVsNCa9xYQwDjei4M6ALx5vaJxxUXJWfyxMtGqdNs+mwgK8554DeZeolbWNatIsO ym8mW7sxXjRH4TqRNvtyJaai5MjOT7RLivg2lGGTFWr2PQ5Yb4E8tgomHMrVeBMFNY3w hcNepXbD9F2XCnhc3EZzT+f+/LKaDyk6qjrBErKTho1a6t26xdjWl8/Oj7hPRbSRDkq3 hugg== X-Gm-Message-State: ALoCoQkaNfsbK2ZSy5Ync6J4ivLERqJGjvUPj+AGCohKt5t+bBQDVYYncog9lUlQeQVIYGm+e+3h MIME-Version: 1.0 X-Received: by 10.60.134.73 with SMTP id pi9mr6413144oeb.3.1421338260609; Thu, 15 Jan 2015 08:11:00 -0800 (PST) Received: by 10.202.214.146 with HTTP; Thu, 15 Jan 2015 08:11:00 -0800 (PST) In-Reply-To: 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> <85F6139E-6332-4645-91B8-C852B07EA62A@ajf.me> <54B7DA71.1050905@seld.be> Date: Thu, 15 Jan 2015 18:11:00 +0200 Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: Jordi Boggiano , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: narf@devilix.net (Andrey Andreev) Hi, On Thu, Jan 15, 2015 at 5:31 PM, Pavel Kou=C5=99il wro= te: > On Thu, Jan 15, 2015 at 4:19 PM, Jordi Boggiano wrot= e: >> >> Right now, or with only weak hints, if a library decides to implement st= rict >> typing, they'll skip the scalar hints and check types with something lik= e >> the assert lib [1]. A user calling it with random data would *always* ge= t >> exceptions. There is no way for the library to use scalar hints to play = nice >> with weak-typed callers as it would not be able to type check anymore in >> that case. >> > > Why would the libraries writers use the checks inside the method > instead of the typing, even in the case of the weak typing? I don't > see a single reason to do so, because if they ask for an "int" in the > method signature, they will get an int or the method won't get called > at all. See the example in the RFC with the "if (!is_int($i))". You're basically asking what's the difference between weak and strong typing ... it's rather philosophical. It's the intent that's important, not the end result, which is why I see the caller-controlled switch as pointless. Cheers, Andrey.