Browse thread
The Implicit Accumulator: a design pattern using optional arguments
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Thomas Fischbacher <tf@f...> |
| Subject: | Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments |
Jon Harrop wrote: > Basically, you memoize strings: > > # 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> ...which is, of course, just a consequence of the OCaml drawback that there is no proper "symbol" data type (which actually would be useful, in particular in conjunction with proper EQ hash tables)... By the way, the Perl interpreter does the same thing with script-constant strings, also using this to provide "effective almost-symbols". -- best regards, Thomas Fischbacher tf@functionality.de