Version franaise
Home About Download Resources Contact us
Browse thread
The Implicit Accumulator: a design pattern using optional arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mattias_Engdegrd <mattias@v...>
Subject: Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments
># let symbol =
>    let m = Hashtbl.create 1 in
>    fun string ->
>      try Hashtbl.find m string with Not_found ->
>      Hashtbl.add m string string;
>      string;;
>val symbol : '_a -> '_a = <fun>

Nice, but perhaps it should return a different type to avoid accidentally
comparing an interned string with a non-interned one?

We would need an accessor to extract the string from an abstract type but
I suppose that would be inlined.