Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Function forward declaration?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Function forward declaration?
On Thu, Apr 08, 2004 at 01:51:21AM +1000, skaller wrote:
> > (Same, by the way, goes for a 'return' statement which OCaml is crying
> > out for).
> I don't think it makes any sense in Ocaml.

This is the sort of thing which I'd like to write.  Note not only the
return statement, but also the regular expression support:

let run dbh q userid =
  if check_permissions userid = Failed then (
    StdPages.error q "Sorry, but you don't have permission to see this";

  let query = q#param "query" in

  if query =~ /^\s*$/ then (
    StdPages.error q "Please enter a query";

  let resource =
    try find_resource dbh query
      Not_found ->
	StdPages.error q "That resource doesn't exist in the database";

  (* Do lots and lots of real processing here. *)

  StdPages.ok q "OK, your query was executed"


That's pseudocode of course, and I'm not saying that it isn't possible
to do this in OCaml already using exceptions, but doing so is very
clumsy compared to having a return statement (and indeed regular
expression support).


Richard Jones.
Merjis Ltd. - improving website return on investment
'There is a joke about American engineers and French engineers. The
American team brings a prototype to the French team. The French team's
response is: "Well, it works fine in practice; but how will it hold up
in theory?"'

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: