Browse thread
"Ref" and copy of functions
[
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: | Pierre-Evariste Dagand <pedagand@g...> |
| Subject: | Re: [Caml-list] "Ref" and copy of functions |
> Here is yet another solution, using objects, which actually combines > Zheng's and Oleg's ideas. That is, it separates state and function, > but provides only access to state through a cloning method, so that it > is completely type safe. This is just what objects are good at! > > class ['a,'b] arrow (f : 'a -> 'b) = > object (self) method call = f method copy = self end Yet another nice solution I would never have imagined :-) And the performance is quite good : 1.428032 microseconds on my small benchmark (the unsafe Ref implantation takes 0.75 microseconds while the CPS implantation takes 2.7 microseconds). Nevertheless, I have carried out my benchmark on Oleg's implementation and find an impressive performance : 0.74 microseconds ! Now, I will re-write my combinators and see which style better suits my needs. Thanks, -- Pierre-Evariste DAGAND http://perso.eleves.bretagne.ens-cachan.fr/~dagand/