Re: [RFC] Strict operators directive

From: Date: Wed, 26 Jun 2019 07:56:39 +0000
Subject: Re: [RFC] Strict operators directive
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-106065@lists.php.net to get a copy of this message
> Le 26 juin 2019 à 08:50, Christian Schneider <cschneid@cschneid.com> a écrit : > > Am 25.06.2019 um 15:09 schrieb Arnold Daniels <arnold.adaniels.nl@gmail.com>: >> This RFC proposes a new directive 'strict_operators'. When enabled, operators may >> cast operands to the expected type, but must comply to; >> >> * Typecasting is not based on the type of the other operand >> >> * Typecasting is not based on the value of any of the operands >> * Operators will throw a TypeError for unsupported types > > While I understand that some people don't like the way PHP does type conversions I think > this proposal creates a much bigger element of surprise when copying PHP code from one place to > another than all the ..ini-settings ever did. > > It basically creates two languages in one and I won't be able to determine what > $a == 42 > exactly does without having to look at the header of the file. > > I'm inclined to say that if you want to make PHP a new language with a new core type > concept then you should fork it and call it something else to avoid confusion. > > - Chris > Indeed. The directive may make operators more strict in what they accept, but it should avoid changing the semantics. Concretely, we must have either: "120" > "99.9"; // true or: "120" > "99.9"; // TypeError Anything else will bring confusion. —Claude

« previous php.internals (#106065) next »