|
From: | John W. Eaton |
Subject: | Re: Cleaning up C++ input validation of strings |
Date: | Tue, 17 Feb 2015 12:52:34 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 |
On 02/17/2015 12:32 PM, Rik wrote:
I'm sure I haven't gotten everywhere, but I have been trying to improve the input validation in Octave for the reasons above. In cases where the function is expecting an option string, but gets something else, Octave should issue an error and stop so the problem can be corrected.
I could be mistaken, but the notion of conversions was there from the beginning because at the time I think Matlab often allowed numbers to be converted to strings. So there is the possibility that something that would not return true for "is_string" (like a numeric array) would nevertheless have a string_value method that could produce a string. But that doesn't seem terribly useful.
In the cases I mean to clean up, the is_string() function is already in place to do this: if (arg.is_string ()) ... else error ("OPTION must be a string") It's in the ellipsis code that I don't think it is worth checking error_state because I already know the arg is a string and string_value should therefore be able to extract a value without problems and without the need to check error_state.
Yes, I agree. jwe
[Prev in Thread] | Current Thread | [Next in Thread] |