
Jon Cast
Manuel M. T. Chakravarty writes:
So, I guess, I have to extend my example to
bar x = x + 42
I don't know if this counts, but gcc allows:
int bar(int x)__attribute__(const) { return(x + 42); }
which is the exact C analogue of the Haskell syntax.
Sorry, but I would say that it doesn't count as it is a compiler specific extension :-) Nevertheless, a good point.
The majority of `C functions', I believe, (and especially in well-written code) are intended to be true functions, not IO monads. They modify the state for efficiency/ignorance reasons, not because of a conscious decision.
Yes and no. I agree that they are often intended to be true functions. However, it is not only efficiency and ignorance which forces side effects on the C programmer. Restrictions of the language like the lack of call-by-reference arguments and (true) multi-valued returns force the use of pointers upon the programmer. Anyway, I don't want to do C bashing here - although, on this list, I might get away with it ;-) Cheers, Manuel