diff libinterp/octave-value/ov-range.cc @ 18129:e473c4853afc gui-release

enable non-integer ranges as indices by default and deprecate preference * octave.cc (maximum_braindamage): Don't call Fdo_brainded_shortcircuit_evaluation. * error.cc (initialize_default_warning_state): Don't set Octave:noninteger-range-as-index to "error". * octave.cc (maximum_braindamage): Don't call Fallow_noninteger_range_as_index. Don't set Octave:noninteger-range-as-index to "on". * ov-range.h, ov-range.cc (Vallow_noninteger_range_as_index): Now static. Set default value to true. * ov.h (octave_value::index_vector): New arg, require_integers. * ov-base.cc, ov-base.h (octave_value::index_vector): Likewise. * ov-base-diag.cc, ov-base-diag.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-colon.h, ov-complex.h, ov-float.h, ov-flt-re-mat.h, ov-intx.h, ov-lazy-idx.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.h: Make corresponding changes in all derived methods. * ov-range.cc (octave_range::index_vector): If new require_integers argument is true, also require integer arguments regardless of the setting of Vallow_noninteger_range_as_index. * utils.cc (Fisindex): Don't temporarily set Vallow_noninteger_range_as_index. Call index_vector with argument of true. * NEWS: Mention change in default value, warning state and deprecated function.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Dec 2013 23:35:34 -0500
parents 1d2e709bbbda
children c7b68a11074b
line wrap: on
line diff
--- a/libinterp/octave-value/ov-range.cc	Wed Dec 11 22:22:28 2013 -0500
+++ b/libinterp/octave-value/ov-range.cc	Wed Dec 11 23:35:34 2013 -0500
@@ -46,7 +46,7 @@
 #include "ls-utils.h"
 
 // If TRUE, allow ranges with non-integer elements as array indices.
-bool Vallow_noninteger_range_as_index = false;
+static bool Vallow_noninteger_range_as_index = true;
 
 DEFINE_OCTAVE_ALLOCATOR (octave_range);
 
@@ -148,13 +148,14 @@
 }
 
 idx_vector
-octave_range::index_vector (void) const
+octave_range::index_vector (bool require_integers) const
 {
   if (idx_cache)
     return *idx_cache;
   else
     {
-      if (! Vallow_noninteger_range_as_index
+      if (require_integers
+          || ! Vallow_noninteger_range_as_index
           || range.all_elements_are_ints ())
         return set_idx_cache (idx_vector (range));
       else
@@ -690,6 +691,14 @@
 The original variable value is restored when exiting the function.\n\
 @end deftypefn")
 {
+  static bool warned = false;
+  if (! warned)
+    {
+      warned = true;
+      warning_with_id ("Octave:deprecated-function",
+                       "allow_noninteger_range_as_index is obsolete and will be removed from a future version of Octave");
+    }
+
   return SET_INTERNAL_VARIABLE (allow_noninteger_range_as_index);
 }