Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* how to coerce expression type?
@ 1998-12-21 17:17 Dwight VandenBerghe
  1998-12-23 15:01 ` Pierre Weis
  0 siblings, 1 reply; 2+ messages in thread
From: Dwight VandenBerghe @ 1998-12-21 17:17 UTC (permalink / raw)
  To: caml-list

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

  let is_in_table table key = 
     try
         Hashtbl.find table key;
         true
     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.

Dwight




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-12-23 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-21 17:17 how to coerce expression type? Dwight VandenBerghe
1998-12-23 15:01 ` Pierre Weis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox