English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: Functional composition operator?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-12-09 (09:13)
From: John Harrison <John.Harrison@c...>
Subject: Re: Functional composition operator?

Pierre Weis writes:

| In fact we discourage the usage of functional composition as a general
| programming tool

A very bad idea, in my opinion.

|  -- it only save a few characters in programs
|      (Compare
|       let h = f o g 
|       with
|       let h x = f (g x);;)
|  -- it breaks the polymorphism
|     (if defined as
|      let h = f o g 
|      h is not generalized, since its definition is a function
|      application, whereas inline expansion of functional composition
|      let h x = f (g x)
|      being the definition of a function is properly generalized.)

These alternatives are not semantically equivalent. If f and g are
complicated expressions that can be further evaluated, it is often
highly undesirable to perform the evaluation every time h is called,
which is what "let h x = f(g x)" entails.