[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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;
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