Date: Fri, 20 Oct 95 14:53:53 +0100
From: boos@gr6.u-strasbg.fr (Christian Boos)
Message-Id: <9510201353.AA20016@gr6>
To: "Makofka, Doug (HT-MS)" <dmakofka@gic.gi.com>
Subject: output_value
In-Reply-To: <30871CFF@gicpo2.gic.gi.com>
Doug Makofka writes:
> could someone comment on the difference between:
> do_list (output_value chan) ProductionLst
> and
> output_value chan ProductionLst
The second form is often better, since all you need to do for
retrieval and use is something like :
do_list SomeCrazyFunctionOnProductionValue
(input_value chan : ProductionValue list)
However, if your 'ProductionLst' is constructed piece by piece, and if
it may grows very large, then you need perhaps the first form, but in
a slightly different way that the one you suggested. The 'do_list ...'
you wrote only outputs ProductionValues, without any structure along
them.
So, you'd better write :
type 'a option = Some of 'a | None;;
do_list (fun p -> output_value chan (Some p)) ProductionLst;
(* - maybe multiple times - *)
(* and, when you're done : *)
output_value chan None
Latter, you can retrieve your production values one by one:
let do_production_value_chan f chan =
let rec do_one () =
match (input_value chan:ProductionValue) with
| Some p -> f p; do_one ()
| None -> ()
in
do_one ()
;;
Hope it helps!
---------------------------------
Christian Boos