
10 Aug
2010
10 Aug
'10
5:36 p.m.
On Tue, 10 Aug 2010 18:27:49 -0300, you wrote:
Nope. For example, suppose we have:
int randomNumber(int min, int max);
Equivalentely:
randomNumber :: Int -> Int -> IO Int
In Haskell if we say
(+) <$> randomNumber 10 15 <*> randomNumber 10 15
That's the same as
let x = randomNumber 10 15 in (+) <$> x <*> x
If we had in C:
return (randomNumber(10, 15) + randomNumber(10, 15))
That would not be the same as:
int x = randomNumber(10, 15) return (x + x)
I think you're misinterpreting what Martijn is saying. He's not talking about referential transparency at all. What he's saying is that in a language like C, you can always replace a function call with the code that constitutes the body of that function. In C-speak, you can "inline" the function. -Steve