Version française
Home     About     Download     Resources     Contact us    
Browse thread
The Bridge Pattern in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christopher L Conway <cconway@c...>
Subject: Re: [Caml-list] The Bridge Pattern in OCaml
Daniel,

This is very clever! But I might do better to just use objects...

Considering how stylized the declarations are in your example (i.e.,
type 'a t, type 'a t_scope = { bind_t : 'b . 'a t -> 'b }, etc.), I
wonder if one couldn't devise some syntactic sugar?

Chris

On Wed, Mar 19, 2008 at 12:51 PM, Bünzli Daniel
<daniel.buenzli@erratique.ch> wrote:
>
>  Le 19 mars 08 à 17:29, Christopher L Conway a écrit :
>
>
>  > In short, the Bridge Pattern is applicable when a client needs access
>  > to operations F, G which can be provided by a variety of underlying
>  > implementations X, Y, or Z. If the specific implementation isn't
>  > important, you create an interface B (a "bridge") with operations F
>  > and G, and write both the client and the implementations to the
>  > interface B. The client should then be able to access X, Y, or Z
>  > interchangeably, e.g., by taking the implementation as an argument at
>  > initialization.
>
>  You need existential types. They can be encoded in ocaml, see here [1]
>  the abstract counter datatype that does just what you describe above.
>
>  Best,
>
>  Daniel
>
>  [1] http://caml.inria.fr/pub/ml-archives/caml-list/2004/01/52732867110697f55650778d883ae5e9.en.html
>
>  _______________________________________________
>  Caml-list mailing list. Subscription management:
>  http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
>  Archives: http://caml.inria.fr
>  Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>  Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>