caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] syntax for variable arity?
@ 2001-08-30 21:45 Michael Leary
  2001-08-31  7:35 ` Remi VANICAT
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Leary @ 2001-08-30 21:45 UTC (permalink / raw)
  To: caml

I want to write a function to abstract a series of functions with different
numbers of args like these two:

let debug message = printf "Debug %s\n" message; fso
let debug_line start_angle start_radius end_angle end_radius =
  printf "DebugLine %f %f %f %f\n" start_angle start_radius end_angle end_radius;
  fso


I was thinking of:

type command =
  Debug
  | Debug_line
  | ...

let com command _ =
  match command with
  | Debug ->
      doit "some special format string" _
  | Debug_line ->
      doit "other format string" _

let doit _ = printf _ ; fso (* fso defined elsewhere *)


let () = com Debug "debug message"
...
let () = com Debug_line start_angle start_radius end_angle end_radius


I know _ matches any value(s??), but I'm not clear on how to use the
match elsewhere...  am I close?  Is there a better way to structure this?  

-- 
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2001-08-31  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-30 21:45 [Caml-list] syntax for variable arity? Michael Leary
2001-08-31  7:35 ` Remi VANICAT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).