Path: csiph.com!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: I don't get it Date: Sun, 11 Apr 2021 14:33:56 +0100 Organization: A noiseless patient Spider Lines: 101 Message-ID: <875z0tq723.fsf@bsb.me.uk> References: <1e965vkgenq7l$.hqmrkifgr4m5$.dlg@40tude.net> <586d1b88-77d5-42b0-ae5b-7506307df499n@googlegroups.com> <957a79db-946e-4f23-931a-ef7d4f0dbb3cn@googlegroups.com> <305fecc4-43da-4378-8430-ed10ac4dbe5bn@googlegroups.com> <20917gl3dv8shs6qqf1dqginq69e50aa54@4ax.com> <8735vytcwa.fsf@bsb.me.uk> <87lf9qrozz.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="0eb5575dba7d605a9a45ceaa8efe2197"; logging-data="20608"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+17mgWi9RVbXbM1PNOEKPBcTwfD0lB9Vw=" Cancel-Lock: sha1:RfEIryjLoe5gdGcFUneBUgekl9M= sha1:3f98qKrPWN4BY/jlCQCGius/hho= X-BSB-Auth: 1.2aee89c1eddfd309ca65.20210411143356BST.875z0tq723.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:39900 The Natural Philosopher writes: > On 10/04/2021 19:08, Ben Bacarisse wrote: >> The Natural Philosopher writes: >> >>> On 10/04/2021 15:47, Ben Bacarisse wrote: >>>> The Natural Philosopher writes: >>>> >>>>> On 09/04/2021 20:01, John G Harris wrote: >>>>>> On Fri, 9 Apr 2021 10:03:13 +0100, The Natural Philosopher >>>>>> wrote: >>>>>> >>>>>> >>>>>>> After spending two days some years ago I discovered that IE and Firefox >>>>>>> differed in their handling of comparisons of numerical and string data, >>>>>>> and that something like >>>>>>> >>>>>>> if('1'== 1) >>>>>>> >>>>>>> was handled differently in each browser. >>>>>>> >>>>>>> As with all loosely typed languages, bugs in your code are trumped by >>>>>>> bugs in the language itself. >>>>>> >>>>>> Was that before or after they claimed to conform to ECMA 262? If >>>>>> after, one or both browsers had a bug, not the language. If before, >>>>>> that's what you get with USPs. >>>>> >>>>> It was around 2007 give or take. IE6 and XP was current. I coded for >>>>> firefox, it broke in IE6. >>>>> >>>>> I actually checked the language spec. As far as I cam remember the >>>>> spec was explicit, that you converted to whatever the target of an >>>>> assignement was in a mixed type operation, but in a conditional there >>>>> was no assignment type... >>>> >>>> So you looked in the wrong place. I don't think that adds much useful >>>> information. ECMA 262, 3rd edition (2000) is very clear about the >>>> conversions required by the == operator (section 11.9.1 and 11.9.3). >>>> For the record, the string should be converted to a number (and the >>>> algorithm for doing that is given in great detail too). >>>> >>>> So it's not an issue with the specification. Testing in IE6 running on >>>> XP I find that the conversion is done correctly. Did Mozilla really >>>> have such a crude bug, and if so, did you really code for that despite >>>> the specification being clear? >>>> >>> All I know is that IE6 and firefox gave different results and it was >>> down to an implicit cast in a conditional statement. The code I have >>> now - dated 2008, after fixing - simply turns everything explicitly >>> into a Number()....so I assume that firefox was doing that implicitly >>> and IE6 was not. >> >> I've tested it on IE6. Unless IE6 is a Heisenberg browser, it does the >> conversion correctly. >> >>> You can defend the language all you like - I was past caring. >> >> I'm not defending the language. >> >>> I had a job to do and IE6 and firefox produced completely different >>> results on the same web page, because of casting. Forcing everything >>> to a number whether it needed it or not fixed the issue. >> >> Maybe is was Mozilla that got it wrong, or maybe you are >> mis-remembering? >> > There was no right or wrong as I recall. Two browsers interpreted the > spec differently because the correct interpretation was not clear. I don't think you have read the specification. I can't see any room for misinterpretation in this case. You made it clear that you had originally read the wrong part of the specification so you can hardly claim to be a reliable source for what the specification says. > I coded for Mozilla. It worked, Others tried IE6, it didn't work. I > scattered explicit Number() casts throughout my code, it worked for > everyone. Then you mislead people with your example, because IE6 does not get that conversion wrong. I can't be sure that Mozilla did not (but I would be very surprised) but IE6 is readily available for testing. > At some level mozilla was casting to a number, In the case you cited, that is correct (and very clearly required by the specification). > but IE6 wasn't. I tested it on IE6 and it correctly converted the string to a number in the comparison. I think you are spreading confusion. > I spent a little time trying to work out what SHOULD happen, but the > spec didn't cover the exact case. That is not true. I gave you the section numbers that explain the required conversions in an equality comparison (the case you cited). -- Ben.