Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81575 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4446 invoked from network); 2 Feb 2015 09:24:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 09:24:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:52104] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/97-02376-1624FC45 for ; Mon, 02 Feb 2015 04:24:51 -0500 Received: by mail-vc0-f171.google.com with SMTP id hq11so14219695vcb.2 for ; Mon, 02 Feb 2015 01:24:47 -0800 (PST) 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=vegNtuGg88lKwKERMBfjRCfpmHoCDqtWWwE5K3ggYUI=; b=Dhss2Y05Dodw7hfLYzCNRVZMqFxQi+u62NUVYCwMa6XAGLAand78FlGs5fHP8+zq3+ 81QACJi3/+mBYIMrVXVKT0MKbpbBd+jHCjQTEZh3ZR5nsaikywhR7CnvzGPC+wBgvOog jqO1aHLv22O6V4kyQv3ooJhyoWEy3E0HMKbi9fYr0OJBMh5m63+U4eRapcHyQLPgaXR+ 2gYU3TfhCHZoWOdN3r1icMmQHPTm6OXTSMkvtMie3D+BFeJKbAQc7UoLrrzK5S7y8vRx eBNgAfJYm6bP8VNcgCpXLwrrFbqYziBKwHAdRhkGweTWsfRXzv0hGvvTB4aSYSVB/mki Bytw== X-Gm-Message-State: ALoCoQnyW58SWtNnVq3DCmOxQDv6h3Rbtl71n7Jj3nmnFu1MHlAxHEnficK1VRcbO7tIox/jaIV8n4erMpjFXkL0A5CWGBIid6auilSwvQqvZR/iWAit6KU02vQFQJ0MG2sz1ZHPF6eT3ywEznLgrJzKK5bc2h+u7g== MIME-Version: 1.0 X-Received: by 10.221.21.131 with SMTP id qs3mr11271644vcb.33.1422869087068; Mon, 02 Feb 2015 01:24:47 -0800 (PST) Received: by 10.52.74.73 with HTTP; Mon, 2 Feb 2015 01:24:46 -0800 (PST) In-Reply-To: <1E54E93F-8CE1-469F-BE1F-DD2F1DF76E39@ajf.me> References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <1E54E93F-8CE1-469F-BE1F-DD2F1DF76E39@ajf.me> Date: Mon, 2 Feb 2015 13:24:46 +0400 Message-ID: To: Andrea Faulds Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a11339f8a7f3ca4050e1786cf Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: dmitry@zend.com (Dmitry Stogov) --001a11339f8a7f3ca4050e1786cf Content-Type: text/plain; charset=UTF-8 On Mon, Feb 2, 2015 at 11:41 AM, Andrea Faulds wrote: > Hi Dmitry, > > > On 2 Feb 2015, at 07:02, Dmitry Stogov wrote: > > > > As I already told, in my opinion, version 0.1 was the perfect solution > that > > fit into PHP semantic very well. > > I don't like the original. Weak types work to a degree, but they don't > fulfill the use case of a lot of developers, and consequently the RFC > wasn't too popular outside internals. > I sent a separate email to collect use-cases for strict typing. Please, answer there. > > > declare(strict_types=1); - is really weird solution. > > It is unusual, that is true. But it has some benefits. > > > It changes type hinting behavior per file scope, so, just to try strict > > type hinting in a big project, people will have to change every single > PHP > > file. > > From the RFC text, I didn't completely understand, if declare() affects > > call site or declaration.ans > > Ah, my bad. It affects function calls and return statements within the > declare block, or remainder of the file if there's no declare block. So > parameter types are checked using the mode chosen by the calling code, > while return types are checked using the mode chosen by the called code. > not your bad, it's exactly what I read, I just couldn't believe that. > > > Will we able to call the same function using weak > > type hinting from on file and with strict from the other? > > Yes, for the parameter type hints anyway. That means that strict and weak > code is interoperable without enforcing a model on each other. > At first I thought, this is ugly solution. Now I'm not completely sure. > > > "The strict type checking mode also affects extension and built-in PHP > > functions", sin(1) - error !!! > > That particular case is probably unpopular - although strict type hinting > for ints and floats can prevent nastier errors later (float out of int > range, or silent loss of precision from int to float). > I see, but this would require declare(strict_types=1) everywhere that would turn PHP into Java. > Strict type hinting is not suitable for PHP by definition (as a weakly > > typed language), however, I see, it may be useful in some cases. > > I would prefer to have "weak" types at first, then think about > introducing > > ability to switch to "strict" type hinting in context of use-cases. > > That'd be possible, but I fear that we'd just end up with weak typing only > and no strict solution. Regardless of its merits, a large portion of the > community is in favour of a strictly-typed solution. There are also a lot > of people who are in favour of weak typing. So, this RFC tries to make a > compromise. > I see, but I afraid that compromise is worse than one or the other. Thanks. Dmitry. > > Thanks. > > -- > Andrea Faulds > http://ajf.me/ > --001a11339f8a7f3ca4050e1786cf--