Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106076 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78962 invoked from network); 26 Jun 2019 15:31:09 -0000 Received: from unknown (HELO mail-ot1-f52.google.com) (209.85.210.52) by pb1.pair.com with SMTP; 26 Jun 2019 15:31:09 -0000 Received: by mail-ot1-f52.google.com with SMTP id r6so2375151oti.3 for ; Wed, 26 Jun 2019 05:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=WRf0o49F/Roe7Tw32Zcgi2mOyt/rZw60DGgMKdhGKhY=; b=La8bNUGi3WXtEfU6N7NKjG9Y627Fkx7W8P9xASEyV7O60QGVzAAZYkWVYMkoM3wwCO BkCs5K6xtDC1+dkcU5mt18auq+1OtXe15UWsKySMqocYI3PUo4q3HkBvXEOxGz4v2Aws DKPG2unibAGaM/8ChhGxIpkjHbaL3YhLN/dS5TckkYL1b6emcxeOsqCWYMHq1hKXU391 d/fUKTnBqqvN0g66XcZ2xUaZf9HAtF/0Bgom9pIRRlpp24vQUoTYeVF8qp1l4GWutINR gluNFKbv/8btw9jSRaWUmppEhqujxe4Dsp1A6tQjt4kzjYBLmssd7oMyf3fNwpwha4V0 Lp/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=WRf0o49F/Roe7Tw32Zcgi2mOyt/rZw60DGgMKdhGKhY=; b=bR5dcbWOQDoWdg5Iv/v616qNEOI80YY1KO7TQDu92e4+AjSttc/0fmNlQWn1E6fjUY uj3+Ro5OpvW43YlMu9cGCeEMmX6tHpmxojF41tYjzZqUWYgTlTDCxhisQQtj1aWhsKAk vw0ZFcq2koENnZbiuwfG1XvO7zYdYJKHRMan9eeRv++zUsq4qmAMYofpu9pw+R0wT0fK t3zLpkkscafnMg7f0ZA0+NYvt3gccgi6hP/Zi34G6eRtcetbLqLI1o8KPOW7Q7AtK9Td pPO388oxvY25Xl48k9j8QbwbP/VDhlkkxLTWnY0VwLwjT22OpcEQ/pbG9jxpAkQiQqmR WYZw== X-Gm-Message-State: APjAAAVR2fSlDrKZsPeLa9vaGQOXQ7UOjcHt9DJSGT2fzhXx2y+2HlUz LuCKj1Z6Ybd8neccq/uxlO3/czU4xO9UUUcWgvdBuEtjcAc= X-Google-Smtp-Source: APXvYqyINgS10gSRfUMOzv8s9wLrkRJP8rxFJOaEYqW8ydFZeFnMJNbepAvqsPcEZuUr0UN9PhJGhNzEm2+KYx0M1o8= X-Received: by 2002:a9d:2c41:: with SMTP id f59mr3095817otb.268.1561553252696; Wed, 26 Jun 2019 05:47:32 -0700 (PDT) MIME-Version: 1.0 References: <6D1026FF-ECF1-4604-91A8-D290D37CC238@cschneid.com> <20190626111846.GB16895@phcomp.co.uk> In-Reply-To: <20190626111846.GB16895@phcomp.co.uk> Date: Wed, 26 Jun 2019 14:47:21 +0200 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="000000000000ecc8ba058c3972ca" Subject: Re: [PHP-DEV] [RFC] Strict operators directive From: arnold.adaniels.nl@gmail.com (Arnold Daniels) --000000000000ecc8ba058c3972ca Content-Type: text/plain; charset="UTF-8" On Wed, Jun 26, 2019 at 1:18 PM Alain D D Williams wrote: > On Wed, Jun 26, 2019 at 12:00:18PM +0100, Rowan Collins wrote: > > > Perl is a notable contrast: the types of operands are deduced based on > the > > operator, but there are different operators to force them to different > > types. So `23 < 4` and `"23" < "4"` are both numeric comparisons, so > return > > false; but `23 lt 4` and `"23" lt "4"` do string comparisons, and return > > true. That way the user's intent is clear, but you don't have to manually > > cast values or remember how different combinations will be interpreted. > > IMHO the Perl way is better: the different operators mean that I will get > what I > want, I don't need to worry about an accidental type juggle; it is also > (presumably) faster as the run time does not need to: look at a string, > decide > if it could be a number and maybe change what it does. > > The big problem is backwards compatibility, so new operators would be > needed: > > string compare: lt, gt, etc, not much of a problem > > numeric compare: #< #> would be nice were it not that # means comment. > > > Note that using a directive means there is no inherit backward compatibility issue. We're talking about copy/pasted code sniplets only. Solving the issues presented, maintaining BC, without the use of a directive would require the addition of multiple type-specific operators. String compare, numeric compare, array compare, etc, etc. PHP code would become unrecognizable. I'm not a fan of that alternative. Arnold --000000000000ecc8ba058c3972ca--