I'll make this a "formal" call: should we rename the resize() methods
in vxl (in vnl, vbl, etc) to make_size()?
My argument is that the STL has introduced the notion of a
content-preserving resize(). That is, the container will keep intact
as much of the old content as possible. None of the resize() methods
in vxl have this property. Instead, if the size is correct, it does
nothing, and if the size incorrect, it simply deallocates the old
memory and allocates a new chunk.
I propose to call this behaviour make_size(). This will clearly mark
the behaviour of the vxl-resize and STL-resize as different, making it
less confusing to vxl newcomers.
When I first saw resize() being used, I hesitated because I thought it
was an unnecessarily expensive operation in that context. Had the
method been named make_size(), I would not have applied my STL
preconceptions to it.
I argue that modern C++ is closely tied to the STL, and therefore we
must cater for STL semantics and notions in our interfaces.
Ian Scott has argued that it is not much of a problem, and that it's
just something you get used to. But he seems to not mind either way,
as long as it's consistent.
I've already committed a change to vnl_vector and vnl_matrix
deprecating resize in favour of make_size. (Admittedly, the commit was
accidently part of my vnl_vector_fixed commits. Sigh.) I suggest we do
the same everywhere: deprecate resize() in favour of make_size(). We
could remove resize() after a few releases.
Comments?
Amitha.
|