Re: Freeze break request for glibmm API



On Mon, 2007-09-10 at 18:13 +0200, Daniel Elstner wrote:
> 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));

Ah, that's enough, I think.

> 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.

Please mention the ambiguity in a comment to stop anyone from adding
this in future.

> 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.

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com




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