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] syntax for variable arity?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-08-31 (00:33)
From: Michael Leary <leary@n...>
Subject: [Caml-list] syntax for variable arity?
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;

I was thinking of:

type command =
  | 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:  FAQ:
To unsubscribe, mail  Archives: