Topic: Pure functions


Author: witless@attbi.com (Witless)
Date: Sat, 11 Jan 2003 17:26:43 +0000 (UTC)
Raw View
James Kanze wrote:

> nagle@animats.com (John Nagle) wrote in message
> news:<3E1DC072.4060407@animats.com>...
> > C and C++ don't have a way to specify that a function is a "pure
> > function" in that sense.  They should.
>
> That's another question.
>
> Even an omniscient compiler can't detect this.  Functions like acos may
> set the global variable errno, which means that they aren't pure
> functions, in the mathematical sense, even though we want the compiler
> to treat them as such.

Which is an excellent reason for the language to provide a mechanism for the
programmer to explicitly inform the compiler of his intentions.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]