octave-maintainers
[Top][All Lists]
Advanced

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

Re: error function


From: John W. Eaton
Subject: Re: error function
Date: Mon, 14 May 2007 15:24:53 -0400

On 14-May-2007, Shai Ayal wrote:

| I am trying to implement a color_property which can aslo have
| radio_values, i.e. it can be a rgb triplet or "auto" or "none".
| 
| let's say I want to get the rgb value from the color_property. first I
| want to check that the value is not "auto". I thight of something
| along the lines of
| 
|   const double* color_property::rgb (void) const
|   {
|     if (current_type != color)
|       error ("color has no rgb value");
| 
|     return color.rgb ();
|   }
| 
| where current_type determines if the color_property's value is a color
| or radio_value and color is the internal color_value object which has
| a rgb () method.
| 
| so in a code using these properties, I would do:
| 
| const double* lc = linecolor.rgb ();
| if (!error_state)
|   glColor3d(lc);
| ...
| this is similar to checking the input argument type in a DLD function.
| Does this seem OK?

If this error condition is a real error that you can't recover from,
then I think this approach is fine.  If it is something you can
recover from, then I think you need to find a way to avoid calling
the error function.

BTW, if the value is "auto" then shouldn't your rgb function compute
the RGB value and return a valid RGB triplet?  What is supposed to
happen if the value is "none"?

jwe


reply via email to

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