Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81662 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74046 invoked from network); 2 Feb 2015 22:30:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 22:30:14 -0000 Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.171 as permitted sender) X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.214.171 mail-ob0-f171.google.com Received: from [209.85.214.171] ([209.85.214.171:63056] helo=mail-ob0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D6/1A-25089-07AFFC45 for ; Mon, 02 Feb 2015 17:30:09 -0500 Received: by mail-ob0-f171.google.com with SMTP id gq1so10543692obb.2 for ; Mon, 02 Feb 2015 14:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=TjgwJmtbKPBfLqaU26kCsFVtbfW+4s88SCTU1e9cdOI=; b=Jv9hyGUU0Py4NwALkjFLLh4xTxD00VnecDrKfBVhnzRlCPSE4fo85BJRy/EWjl+9la HC5RWKgV1oivSEfq6fLYD2/8aud61lVYLBD5+iz+bAkrxCh24I/jCOGlyGFXUyjH0DX6 Bv1Thpr0fzPfud/6KC2H5H1zrtMMUqPwaWWLuwD+pV2wTv2rBgzVw/3UsVieLUxC134x LHYsEmTzGrSDoDKFvnDUyA6rwC1axWFk+rIvzWNtdT0UKdwePymTQExUnRGdn/JGVL6m ERN2I53cSxO0bLDPfN9DhlzUsuakznRnOoBUO0z8zWnrawhEHJ8vxGOoGV3xgQE/N9j2 qiXg== X-Received: by 10.202.60.66 with SMTP id j63mr12510869oia.83.1422916205516; Mon, 02 Feb 2015 14:30:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.60.14.5 with HTTP; Mon, 2 Feb 2015 14:29:45 -0800 (PST) In-Reply-To: References: Date: Tue, 3 Feb 2015 00:29:45 +0200 Message-ID: To: Dmitry Stogov Cc: PHP Internals , Andrea Faulds , Nikita Popov Content-Type: multipart/alternative; boundary=001a113cca3ef99e36050e227ece Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: arvids.godjuks@gmail.com (Arvids Godjuks) --001a113cca3ef99e36050e227ece Content-Type: text/plain; charset=UTF-8 2015-02-02 11:12 GMT+02:00 Dmitry Stogov : > hi, > > could you please write down few use cases, when strict scalar type hints > are really useful. > > Thanks. Dmitry. > Hello Dmitry, At the moment, being a user-land dev for a little bit more than 10 years, I just don't see the usage for the strict type hints at the moment. I just can't imagine it actually being usefull for the masses. Yes, some deep core library code may use them, wrapped in layers and layers of code, so deep, that it actually works. But on a day to day basis? No-no-no-no-noooo. I'll probably mess it all up quite fast and end up just stripping those away. It's quite a foreign concept for me for the PHP code (not that I haven't written in strict typed languages, but I had to define all the variables up front in the program). On a day to day basis I juggle a lot data back and forth - parsing an XML document comes to mind immedeatly (because I have tons of them, with all kinds of data), i handle a lot of JSON data (including input, that is mostly strings, because it comes from forms in text form), memcached is other example. CVS files. And so on. It's the little everyday stuff that after years just feels natural to do that will be affected and cause grief, and these days many liek to jump on the hype train without any regard for the others. So, for me, the first step is to get the "converting", "Weak" or whatever you call them, type hints into the language. And I have a perfect case of "why" for it. Just look back at how OOP arrived into PHP and how it evolved. PHP 4 (yeah, I remember some from those days still) was very basic, and for me that was a very short phase. Them came PHP 5 with it's more serious OOP aproach and features. And in 10 years look what has become of the OOP feature set? And all of it really fits. It started with the basics and ended-up in a very good state. And most additions that came along had time to be understood and solidify before more was added. People eased in into it naturally and many changed their views on the subject with time. So, I would recomend to start with a small step, see how it's gonna be used and actually get feedback first. Because you can always go stricter if needed, but removing such a major feature like "strict typehints" probably gonna be messy as hell, if even possible if it does not work out. Get the weak type hints in, wrote code, get a feeling for them, understand the impact and then make an informed decision - do we actually need to go stricter? Thanks, Arvids. --001a113cca3ef99e36050e227ece--