Re: forward function definitions

From: Sven LUTHER (luther@maxime.u-strasbg.fr)
Date: Thu Jun 17 1999 - 10:46:13 MET DST


Date: Thu, 17 Jun 1999 10:46:13 +0200
From: Sven LUTHER <luther@maxime.u-strasbg.fr>
To: Pierre Weis <Pierre.Weis@inria.fr>,
Subject: Re: forward function definitions
In-Reply-To: <199906162055.WAA22149@pauillac.inria.fr>; from Pierre Weis on Wed, Jun 16, 1999 at 10:55:31PM +0200

On Wed, Jun 16, 1999 at 10:55:31PM +0200, Pierre Weis wrote:
> > Ah, but you can define a wrapper immediately following the definition of the forwarder function :
> >
> > let f for () = ...
> >
> > ...
> >
> > let for ... = ...
> > let true_f = f for
> >
> > Friendly,
> >
> > Sven LUTHER
>
> Yes you can do so, but you once again get the same polymorphism
> problem:
> 1) If for is used polymorphically in the body of f you're dead.
> 2) true_f will be monomorphic as well, unless you eta-expand it as in:
> let true_f () = f for ()
         
Ok, true, but it solves the lisibility problem.

I have a similar problem :

i am intenting to write a little function, using the mlgtk gtk+ bindings, that
will popup a dialog window and ask the user for a string. The dialog window
will activate a callback when i type enter in the entry widget.

here is what i plan to do :

let todo = ref None

let activate entrywidget =
  let s = (* stuff to get the string in the entry widget *)
  in match !todo with
    | None -> raise Error
         | Some f -> f s

let get_string f = match !todo with
  | Some f' -> ()
  | None ->
    let () = todo := Some f
         in (* stuff to open the dialog box,
        * and connect the activate handler to it
        *)

is this the best way to do things like that, what other possibilities are there
?

Friendly,

Sven LUTHER



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET