octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Array constructor backward compatibility problem


From: John W. Eaton
Subject: Array constructor backward compatibility problem
Date: Wed, 19 Jan 2011 18:08:58 -0500

On 19-Jan-2011, John W. Eaton wrote:

| Please see the following problem that was reported on the help list:
| 
|   https://mailman.cae.wisc.edu/pipermail/help-octave/2011-January/044288.html
| 
| We apparently have a problem with backward compatibility regarding the
| Array constructors
| 
|   explicit Array (octave_idx_type m, octave_idx_type n)
|   explicit Array (octave_idx_type m, octave_idx_type n, const T& val)
| 
| Previously, we had
| 
|   explicit Array (octave_idx_type n)
|   explicit Array (octave_idx_type n, const T& val)
| 
| And we did not have any Array constructors taking two dimension
| arguments.
| 
| Note that
| 
|    // Obsolete 1D ctor (there are no 1D arrays).
|   explicit Array (octave_idx_type n) GCC_ATTR_DEPRECATED
| 
| is already deprecated.
| 
| To avoid confusion and prevent a lot of frustration over programs that
| previously worked an will now crash mysteriously, how about doing the
| following:
| 
| Reinstate the 
| 
|   explicit Array (octave_idx_type n, const T& val)
| 
| constructor but mark it as deprecated.
| 
| Delete the new constructors
| 
|   explicit Array (octave_idx_type m, octave_idx_type n)
|   explicit Array (octave_idx_type m, octave_idx_type n, const T& val)
| 
| Where these might be needed, can't they just be handled by calling
| 
|   Array (dim_vector (m, n))
|   Array (dim_vector (m, n), val)
| 
| ?
| 
| There is also
| 
|   Array (const Array<T>& a, octave_idx_type nr, octave_idx_type nc);
| 
| which was not present previously.  Anywhere this might be needed it
| can be replaced by
| 
|   Array (a, dim_vector (nr, nc))
| 
| so I'm not sure why this special case was needed.
| 
| Are there any objections to making this change?

I checked in the following change:

  http://hg.savannah.gnu.org/hgweb/octave/rev/57632dea2446

This will affect anyone who already updated Array constructors from

  Array<T> ra (n);

to

  Array<T> ra (n, 1);

to cope with earlier changes in the development version of Octave.
But I think it is better to preserve backward compatibility (with a
deprecated function warning) for at least one stable release than it
is to worry about backward compatibility with previous development
versions.

This patch also deprecates the Array3.h header file as it is now
obsolete.

I also noticed that we have

  void resize1 (octave_idx_type n, const T& rfv = resize_fill_value ());

  void resize (octave_idx_type n) GCC_ATTR_DEPRECATED

  void resize (octave_idx_type nr, octave_idx_type nc, 
               const T& rfv = resize_fill_value ());

  void resize (const dim_vector& dv, const T& rfv = resize_fill_value ());

For consistency, maybe we should deprecate

  void resize (octave_idx_type nr, octave_idx_type nc, 
               const T& rfv = resize_fill_value ());

as it can be replaced with

  resize (dim_vector (nr, nc), rfv)

Comments?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]