Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!shaftesbury.zen.co.uk.POSTED!not-for-mail From: Nobody Subject: Re: float("nan") in set or as key Date: Sun, 05 Jun 2011 19:15:02 +0100 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.python References: <94dkd3F7k4U1@mid.individual.net> <4de1e3e7$0$2195$742ec2ed@news.sonic.net> <4de22007$0$29996$c3e8da3$5496439d@news.astraweb.com> <4de2d746$0$29996$c3e8da3$5496439d@news.astraweb.com> <4de75dd5$0$29983$c3e8da3$5496439d@news.astraweb.com> <4deb2e65$0$29996$c3e8da3$5496439d@news.astraweb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 25 Organization: Zen Internet NNTP-Posting-Host: 57074da8.news.zen.co.uk X-Trace: DXC=fZZbAOUYa\]G`MCLM Returning a sentinel meaning "an exceptional event occurred" is hardly > unusual, even in Python. str.find() does is, as does re.search() and > re.match(). These are not "exceptional" conditions; if they were, an exception would be used. E.g. dict supports both d.get(key) and d[key] for lookups. The former returns a sentinel, the latter raises an exception. The latter makes sense if you "expect" the key to be present, the former if you don't. >> As for IEEE-754 saying that it's [NAN == NAN] True: they only really >> had two choices: either it's True or it's False. > > Incorrect. They could have specified that it was an error, like dividing > by zero, but they didn't. Specifying an error doesn't remove the requirement to also specify a result. E.g. dividing a finite value by zero produces a result of infinity. In languages which lack exceptions, errors only matter if the code bothers to check for them (if such checks are even possible; C89 lacks ).