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
[Caml-list] ocaml and named constants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-05-23 (17:06)
From: David Fox <dsf@h...>
Subject: [Caml-list] ocaml and named constants
I've noticed that there is no notion of a named constant in ML.  I
sort of assumed that the compiler could determine that uses of a
variable after a declaration like

  let mpg_joint_stereo = 1

could be compiled as a constant provided the value was never altered
and no references to the variable were created.  Does the compiler
actually do this?  I can't see how it could do it for a variable that
wasn't module local.  I ask because it seems odd that camlp4 includes
a feature for creating real defined constants that are textually
substituted before compilation begins.  Would it be a better bet to
use a function like

  let is_joint_stereo head = (mpg_mode head) = 1

and hope the compiler inlines the function?

To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr