Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: forward function definitions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven LUTHER <luther@m...>
Subject: Re: forward function definitions
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