Merge: Introduce Cloneable interface
authorJean Privat <jean@pryen.org>
Tue, 3 Mar 2015 15:04:56 +0000 (22:04 +0700)
committerJean Privat <jean@pryen.org>
Tue, 3 Mar 2015 15:04:56 +0000 (22:04 +0700)
As exposed by #917 a standard API to clone objects could be useful.

This PR propose a Cloneable interface that class can implement.
The specif semantic of what a clone is is domain-dependent, the only suggestion I define is to be POLA and to consider the post condition `self == clone`. It seems sane since the precise semantic of `==` is also domain-dependent. The post-condition is not mandatory since not all classes redefines `==` and maybe some classes could be cloneable without being `==`-able. The reason is that `clone` is instantaneous but the semantic `==` should remain valid all the time. For instance, It could make sense to clone some Iterators but I am not sure what is a sane definition of `==` on them.

As a POC, clone is implemented is the three Array-related classes, Array, ArraySet and ArrayMap.

Pull-Request: #1176
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>


Trivial merge