Re: Freeze break request for glibmm API



Am Montag, den 10.09.2007, 17:00 +0200 schrieb Murray Cumming:

> Daniel, maybe we should add some default value for the RegexMatchFlags
> parameters. Would these overloads still be non-ambiguous if we do that?

Hm, the overloads with the least number of arguments already have
default values for the match_options parameter.

    bool match(const Glib::ustring& string, RegexMatchFlags
               match_options = static_cast<RegexMatchFlags>(0));

    bool match_all(const Glib::ustring& string, RegexMatchFlags
                   match_options = static_cast<RegexMatchFlags>(0));

I'm not sure whether it is a good idea to go beyond that.  For instance,
adding a default argument to

    bool match(const Glib::ustring& string, int start_position,
               RegexMatchFlags match_options);

could render the call

    regex.match("foo", Glib::REGEX_MATCH_NOTEMPTY);

ambiguous.  Or maybe not since the enum argument type is a direct match.
I'd have to try it to be sure.  However, in any case the call

    regex.match("foo", G_REGEX_MATCH_NOTEMPTY);

would introduce a subtle error because the enumeration would be
converted to an integer and interpreted as string start position.

Given that we already have default arguments for the simple cases with
only a string argument, I think it's better to take no chances and avoid
these pitfalls.

--Daniel





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