Browse thread
[Caml-list] Function forward declaration?
[
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: | Issac Trotts <ijtrotts@u...> |
| Subject: | Re: [Caml-list] Function forward declaration? |
On Wed, Apr 07, 2004 at 03:15:19PM +0100, Richard Jones wrote: > On Wed, Apr 07, 2004 at 11:52:17PM +1000, skaller wrote: > > IMHO it isn't forward calling that is broken, > > but global variables. > > A somewhat controversial viewpoint ... While minimising the use of > global variables might be a theoretical desirable goal, they are very > useful when you're actually writing real programs under the schedule > pressure for real users.. > > > > and this can be checked by the compiler. > > > > How? *** > > > > What do you suggest if the compiler > > is not sure if a variable is initialised or not? > > Java bans, Felix allows, Ocaml forces the programmer > > to hack. > > The trouble seems to be that I have a perfectly practical and > reasonable desire to see prototypes added to the language, because, > believe it or now, it helps to solve some problems in the Real World. > Now if there's some deep reason why it's actually impossible I would > understand, but plenty of other languages (eg. C) seem to have > prototypes and they get along just fine. How about this: # let f g x = g x (* Pass the function g as an argument. *) let g x = x*x (* or whatever. *) let f = f g (* Define a fresh f in terms of g and the old f. *) ;; val g : int -> int = <fun> val f : int -> int = <fun> # f 3;; - : int = 9 > (Same, by the way, goes for a 'return' statement which OCaml is crying > out for). If you're looking for clarity, you can use the comment (* return *). If it's for flow control, you can raise an exception. Issac Trotts ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners