world as value

Marco Kesseler mke@oce.nl
Mon, 21 Jun 1999 15:55:57 +0200


>> >
>> >	-- print a table of squares, from 1 to 20
>> >	main =
>> >	    do  x <- newIORef 1		    -- initialize the value of x to 1
>> >		while (testval x (<= 20))   -- loop while the value of x < 20
>> >		    (do xval <- readIORef x
>> >		        putStrLn ((show xval) ++ "\t" ++ (show (xval * xval)))
>> >		      	incr x)		    -- increment the value of x
>> 
>> Why is this better than the following?
>> 
>> main ()
>> {
>>     int x;
>>     for (x = 1; x <= 20; x++)
>>         fprintf (stdout, "%d\t%d\n", x, x * x);
>> }
>
>It's not.  I never said it was.
>I was only arguing that it is not much worse.
>
>You had said that what modern purely declarative languages gave you
>was not the same as the "good old" imperative programming world;
>I argue that they do give you basically the same thing, or at least
>something which is similar enough that it is not much worse.

I was not stating that functional languages do not offer similar
things. I said they do not offer the "good old" imperative world itself.

Anyway, for imperative programming I see no reason to use something
'similar to an imperative language that is not much worse'.

As to the functional example above, well, I think it is far
worse than the C version. Sorry.

cheers,
Marco

---------------------------------------------

Marco Kesseler
Oce-Technologies B.V.
St. Urbanusweg 43, Venlo, The Netherlands
P.O. Box 101, 5900 MA Venlo, The Netherlands
telephone +31 77 359 5158
fax       +31 77 359 5450
e-mail    mke@oce.nl