octave-maintainers
[Top][All Lists]
Advanced

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

Re: message ids for warnings and errors


From: Paul Kienzle
Subject: Re: message ids for warnings and errors
Date: Wed, 7 Dec 2005 20:30:57 -0500


On Dec 7, 2005, at 7:24 PM, John W. Eaton wrote:

On  7-Dec-2005, Paul Kienzle wrote:

| It would be nice if the warning state were automatically
| restored when the function completes, otherwise we are going
| to end up with unwind protect cruft sprinkled everywhere again.

One of the reasons for adding the message-id thing was compatibility.
Having the state scoped would break compatibility.

In CVS Octave, we have 21 knobs for warning control:

  warn_assign_as_truth_value
  warn_function_name_clash
  warn_neg_dim_as_zero
  warn_separator_insert
  warn_variable_switch_label
  warn_associativity_change
  warn_future_time_stamp
  warn_num_to_str
  warn_single_quote_string
  warn_divide_by_zero
  warn_imag_to_real
  warn_precedence_change
  warn_str_to_num
  warn_empty_list_elements
  warn_matlab_incompatible
  warn_reload_forces_clear
  warn_string_concat
  warn_fortran_indexing
  warn_missing_semicolon
  warn_resize_on_range_error
  warn_undefined_return_values

and 12 of them are off by default.  So I guess we have a situation
similar to Matlab, where we will start with

  warning on all

plus the 12 exceptions.

Is it really a problem if the state is global?  Are there very many
(any) places now where we need unwind_protect to play with the warning
state?

~/cvs/octave/scripts$ grep -h "^ *warn_" */*.m */*/*.m | sed -e"s/^ *//;s/ *= */ = /" | sort | uniq

  warn_empty_list_elements = 0;
  warn_empty_list_elements = save_warn_empty_list_elements;
  warn_fortran_indexing = 0;
  warn_fortran_indexing = wfi;
  warn_str_to_num = 0;
  warn_str_to_num = tmp;

~/cvs/octave/scripts$ grep -l "^ *warn_" */*.m */*/*.m | wc
  16      16     357


Similarly, octave-forge has 27 instances, including

  warn_divide_by_zero = 0;
  warn_divide_by_zero = wdz;

Maybe warn could have another state 'expected' which
suppresses the warning in the local scope?  So rather
than:

   wfi = warning('query','octave:empty_list_elements');
   unwind_protect
     warning('off','octave:empty_list_elements');
     ...
   unwind_protect_cleanup
     warning(wfi,'octave:empty_list_elements');
   end_unwind_protect

you would use:

   warning('expected','octave:empty_list_elements');
   ...

- Paul



reply via email to

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