octave-maintainers
[Top][All Lists]
Advanced

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

automatic conversions to character strings


From: John W. Eaton
Subject: automatic conversions to character strings
Date: Fri, 13 Nov 2015 09:36:18 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

As part of eliminating error_state, I just noticed that

  if (arg.is_string ())
    {
      std::string str = arg.string_value ();
      ...
    }
  else
    error ("foobar: arg must be a string");

is NOT the same as

  std::string str = arg.string_value ();

  if (error_state)
    error ("foobar: arg must be a string");
  else
    { ... }

if arg is a numeric value because the string_value extractor attempts to convert numbers to strings (possibly with a warning).

Is it time to stop doing these automatic numeric conversions and require them to be done explicitly in functions that need that behavior?

I'm beginning to think that value extractors that do implicit conversions are kind of evil.

jwe





reply via email to

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