Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106073 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 64089 invoked from network); 26 Jun 2019 14:29:53 -0000 Received: from unknown (HELO mail-io1-f54.google.com) (209.85.166.54) by pb1.pair.com with SMTP; 26 Jun 2019 14:29:53 -0000 Received: by mail-io1-f54.google.com with SMTP id i10so2509403iol.13 for ; Wed, 26 Jun 2019 04:46:16 -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 :cc; bh=qg/faR+xisA2krIrytkyoCvuQDxCej/b3L622GC4noU=; b=PF30r4hsPW1HFp3OdBB643zM1/Kj+5g/jYTEl18TSnnI/m7JfuhS5ik86Znx1Mfwki y6LSe1JSrGOZL3IPu+/lNwWmIk3ynnwyiU4vqyXozEgIFx33h5BkJorYiqvT+IjBNlE3 GRQTz35x9GHulA9B4dD0YHoxTdihap+kFLXAm13lBkFMlAEdzi+h+K6r77duzlaN7ZL6 rghfwd8Dt74R2UxMzxMz8UrqLET5pzhywR8P7YGMdKGmhfxUDy+kcBX6wWS4+66vbix1 AfM+GQyaWj33QxyZwgb9qvy+dhU48foF4I45TBSJfygwe1kQykxsjI3fN31PLzp9pGAq fn/A== 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:cc; bh=qg/faR+xisA2krIrytkyoCvuQDxCej/b3L622GC4noU=; b=CBLjKXTtZEJpfM+iKFcji6OXMNffz4bcCUIKnO8oHVb29e2kvHKJe38MEQbiFbkOEE HgX823iRJrFp5P3Ns24TLJPR1gciJ+JSjH82KhqHuwFikLQeq2AVyKPHBnjxXb2xVnOR G08ru+p0rJ1ogTijUhf5lvwHH8LMs2OBRIBynjwtPBaEWadSofC7GhRzVJ831B3gYNXI nsWxXKGJ3lzvATPxutbnwshui4+XbC/guYJ21ht2DJor/kbg9oeHxSN8gR/DQt/j9rI6 LCg0PzhMCUFBwfbErbKRlhVsO6/KfjRyD/Vm245DRqUivec7c3DyIf54193Eo2iSLn5H Y5sQ== X-Gm-Message-State: APjAAAXUAbZrZwBAxxPzotymwl06JEizgGSjRO5RXdMGVBJqxctezo5A oRAQ+YzVs9xhbO3Sbyw/UYLmepFOnlX2NOkGToo= X-Google-Smtp-Source: APXvYqycUKy43TizTyHi7SemO1D4Mi8WxUpZwN6pRdwtHV+ui6h19D4SXu6QBtJcd0BQHhFZ0Lwk7GQtFRVrzFUO1gI= X-Received: by 2002:a02:b050:: with SMTP id q16mr4476796jah.120.1561549576239; Wed, 26 Jun 2019 04:46:16 -0700 (PDT) MIME-Version: 1.0 References: <6D1026FF-ECF1-4604-91A8-D290D37CC238@cschneid.com> In-Reply-To: Date: Wed, 26 Jun 2019 13:46:03 +0200 Message-ID: To: Claude Pache Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000ca7cb4058c38978f" Subject: Re: [PHP-DEV] [RFC] Strict operators directive From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000ca7cb4058c38978f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > * in some strict mode, reserve `<`, `=3D=3D` etc. for numeric comparison,= and throw a TypeError one of the operand is not numeric; > * If we deem it worth, define a new operators for string comparison. (Although I=E2=80=99m not really sure it is worth: we have `strcmp()` and `= =3D=3D=3D` for byte-to-byte comparison, and the Collator class for alphabetical sorting that actually works in languages not restricted to unaccented latin characters.) It's true that string comparison (sorting) is a much harder problem that cannot be solved without additional knowledge of the encoding of the string; so I agree that it might be better to just throw a TypeError when comparing strings, and leave the user with an operator that only works on numbers, and explicitly use dedicated functions when comparing strings. This makes sense for "<", "<=3D", ">", ">=3D", but what about "=3D=3D" and = "!=3D"? Currently, "11" =3D=3D "11.0"; what would this yield under the new proposal= ? - leave it as is: return true in this case =3D> contradicts the whole purpo= se of the new proposal - throw a TypeError when performing the above comparison =3D> not acceptabl= e either I guess; every language allows =3D=3D and !=3D on strings, forcing t= o use strict comparison operators is a bit weird here. - change the semantics to return false when both operands are strings, and don't match =3D> not acceptable to you as you cannot know what a line of co= de does without checking the header What would you suggest here? Ben --000000000000ca7cb4058c38978f--