Version française
Home     About     Download     Resources     Contact us    
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: Remi Vanicat <remi.vanicat@l...>
Subject: Re: [Caml-list] Function forward declaration?
Richard Jones <rich@annexia.org> writes:

> 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 do it without return nor exception :


let run dbh q userid =
  if check_permissions userid = Failed then (
    StdPages.error q "Sorry, but you don't have permission to see this"
  ) else
  let query = q#param "query" in

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

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

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


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

I don't see what is your problem here...

-- 
Rémi Vanicat

-------------------
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