Browse thread
How to cleanly encode "quasi-constants"?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Daniel de Rauglaudre <daniel.de_rauglaudre@i...> |
| Subject: | Re: How to cleanly encode "quasi-constants"? |
> Right now, I'm using constants (let var = ...) or mutable references
> (let var := ...) to encode such things.
>
> However I'm not satisfied. With constants, I obviously can only modify
> them at compile time. With mutables, I can modify them but potentially
> at any time, meaning potential bugs.
I am not sure I understand your point, but the construction "let var =
..." does not define *compile time* constants: the expression "..." is
computed at *run time*. It can be any computation.
Typically, a program using the Xlib would start with:
let dpy = xOpenDisplay "" in ...
The computation of xOpenDisplay "" is a very complicated computation of the
Xlib, creating a connection to the X server. But the variable "dpy" is not
mutable and then is never modified nor modifiable in the rest of the program.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/