Economical/cheap bicycle light? Re: Bicycle Lighting
On Mon, 08 Apr 2002 08:45:07 +1000, Darryl Chrisp posted:
>> functional languages you need only test that your function returns the
>> correct value. If it does, your function is correct and should always be
> Well, that's a very broad statement, and one that you cannot defend in
> general. Consider the purely functional code below:
> double bar()
> return log(foo());
> Here, your implementation depends on foo() not returning anything less
> than or equal to zero. Checking the return value is not going to make
> this any better because if foo() returns something less than zero it
> doesn't even make sense to produce any value. The point here is that
> this code, which is completely independent of foo(), places an
> implicit constraint on foo(), or is dependent on an implicit
> constraint of foo(). This is similar to code depending on the state of
> an object in an OO language.
If foo() has no arguments in a referentially transparent language, then
it always returns the same value, so bar() need only be tested once.
If foo() returns a value less than zero we bomb out with an exception.
Zachary was quite right.