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
how to coerce expression type?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-12-23 (15:03)
From: Dwight VandenBerghe <dwight@p...>
Subject: how to coerce expression type?
I am converting older ocaml code to version 2.01, and
find that many expressions that passed through the previous
compilers fine now exhibit warning errors due to not being
of unit type.  This happens when I evaluate an expression
for its side effects (the horror, the horror).  Here's an

  let is_in_table table key = 
         Hashtbl.find table key;
     with Not_found -> false;;

I don't want the result back from the lookup, I just want
to know if the key was present.  So how do I "cast" the
find operation to unit, to quiet the warnings?  I've tried
everything I can think of, things like

         (Hashtbl.find table key) : ()

but have not yet hit upon the magic incantation.

Thank you.