Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101442 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22626 invoked from network); 29 Dec 2017 17:13:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Dec 2017 17:13:25 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.25.164 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.25.164 mx208.easyname.com Received: from [212.232.25.164] ([212.232.25.164:60561] helo=mx208.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/CA-47595-1B7764A5 for ; Fri, 29 Dec 2017 12:13:24 -0500 Received: from cable-81-173-133-76.netcologne.de ([81.173.133.76] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1eUyDY-0006mz-1Z; Fri, 29 Dec 2017 17:13:13 +0000 Reply-To: internals@lists.php.net To: Nikita Popov , PHP internals Cc: Larry Garfield References: <72392123-d37b-26df-6886-218f48205f8a@fleshgrinder.com> <58A5ABDF-AA25-46D4-83E7-4DE72E3DFF5E@gmail.com> <757270790.33iDQ9MZ2V@vulcan> Message-ID: Date: Fri, 29 Dec 2017 18:13:08 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Scalar Pseudo-type From: php@fleshgrinder.com (Fleshgrinder) On 12/29/2017 4:37 PM, Nikita Popov wrote: > int|float is the natural type of numeric operations in PHP. Integers > automatically overflow into floating point numbers, so signatures using int > in conjunction with numeric operations are somewhat problematic. > > Having an explicit number type also goes well with an explicit number cast. > PHP internally has a notion of a number cast (which is the basis for > arithmetic operations), but currently does not expose it. As such, number > casts currently have to be simulated using workarounds like +$x. > Not sure I fully understand what you are saying. I mean, the accuracy problem will prevail no matter what because at some point we have to change that long to a double. The earlier the better so users know what they are dealing with. `+$x` seems like something that is only of interest if my source is a string and I don't know if it should be int or float. This on the other hand sounds like something that is happening at the edges of the application. Or maybe you had something else in mind? On 12/29/2017 4:37 PM, Nikita Popov wrote: > Regarding the union type RFCs, from what I remember, one of my personal > issues with it were the complex rules involving scalar type unions in weak > typing mode. It's non-trivial to decide what a value should be casted to if > it does not have the correct type. It's sort of clear what "1.5" passed to > an int|float union becomes, but it's not intuitively obvious what should > happen if you pass "foo" to a bool|int union, etc. > Why exactly is it necessary to support weak mode together with unions and intersections? It is obviously unclear in many situations what should happen, so why not simply bail like in strict mode? I mean, strict mode was added for backwards compatibility reasons. This is a new future, there is no backwards compatibility. Anyone using it shall abide to the strict rules of it. -- Richard "Fleshgrinder" Fussenegger