RE: Functional composition operator?

From: Don Syme (
Date: Wed Dec 09 1998 - 13:00:39 MET

From: Don Syme <>
To: "'Pierre Weis'" <>,
Subject: RE: Functional composition operator?
Date: Wed, 9 Dec 1998 04:00:39 -0800

> Anyway, if you can manage the additional complexity, there is no
> problem at using a highly ``composing'' style in Caml. However, in my
> mind, it is not a good idea to promote this style, especially for the
> working programmer.

I think it simply depends on what you're doing: highly symbolic work like
theorem proving certainly benefits from a compositional style, but for
anything involving complex state control (interfaces, objects, networking,
i/o, whatever) it is not so appealing. I think the latter tasks are what
Pierre means by "the working programmer" -- (a rather loaded term in the ML
world? ;-) )

> Let alone the case when
> these expressions involve side-effects: then, if you still insist at
> composing them on the fly, you get an order of evaluation dependant
> program and this must be carefully avoided.

Some invisible uses of side effects are highly compatible with a functional
style, e.g. memoizing and building tables based on an environment, and
certainly John uses these effectively in his programs. Externally visible
effects are, of course, to be avoided when using a compositional approach,
as Pierre suggests.

So you're both right, and that's just why CaML is so appealing: when doing
structural data manipulations it supports the functional model, but it also
supports state-based programming in a very traditional fashion (mutable
record fields, objects, arrays, for-loops, while-loops, begin-end statements
all being part of this). For example, I would teach both styles as part of
a CaML programming course, and I frequently use both styles in different
modules of the one program.


This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:17 MET