Of what use is 'lambda'???

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Sep 26 08:55:43 EDT 2000


Tue, 26 Sep 2000 09:49:59 GMT, Jonadab the Unsightly One <jonadab at bright.net> pisze:

> > One can certainly declare "procedures" in C that do not return anything
> > (declare a function as returning void), so that's not true of C.
> 
> I thought void was added later as a concession to people who don't
> like throwing away values?  Didn't C originally return a value from
> every function?

Indeed: that's why f() {...} used to mean int f() {...}.

"Procedures" formally returned int, which happened to work even if
there was no return statement, assuming that clients didn't look at
the result.

> I'm not sure how you could do things like file I/O and user
> interaction without functions having side effects.

In Haskell I/O actions are not expressed as functions, but as an I/O
action type. Function application cannot execute I/O actions itself -
it can at most construct, combine and return them. This goes up to
main, so conceptually the action of the whole program is executed
on a different semantics layer. In practice it looks very similar to
imperative programming.

In Clean I/O actions are expressed as functions from World to World,
where the type system ensures that the World token is neither
duplicated nor lost. So functions of the interface not involving
World cannot perform I/O - you could not apply I/O primitives inside
them because you don't have a World value to pass to them and you
could not do anything with the World they return. Functions wanting
to perform I/O have an interface that ensures that they are used in
a predictable order.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list