caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocaml and named constants
@ 2001-05-23 17:06 David Fox
  2001-05-28 12:32 ` Xavier Leroy
  0 siblings, 1 reply; 12+ messages in thread
From: David Fox @ 2001-05-23 17:06 UTC (permalink / raw)
  To: caml-list

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?

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-06-01 17:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-23 17:06 [Caml-list] ocaml and named constants David Fox
2001-05-28 12:32 ` Xavier Leroy
2001-05-29  1:07   ` John Max Skaller
2001-05-29 12:12     ` Andreas Rossberg
2001-05-29 17:16       ` John Max Skaller
     [not found]         ` <skaller@ozemail.com.au>
2001-05-30  9:46           ` Wolfgang Lux
2001-05-29 13:50     ` Luc Maranget
2001-05-30 16:50       ` Brian Rogoff
2001-05-31  9:22         ` Luc Maranget
2001-05-31 16:34           ` Brian Rogoff
2001-06-01  4:39             ` David Fox
2001-06-01  1:45           ` John Max Skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).