Ok() and IsOk()

Francesco Montorsi f18m_cpp217828 at yahoo.it
Wed Oct 4 14:43:02 PDT 2006


Julian Smart ha scritto:
> Francesco Montorsi wrote:
>> Hi all,
>>    I found annoying that some wx classes use the Ok() function name 
>> while others use IsOk()...
>>
>> I've noticed that basically the classes using Ok() are the GDI objects 
>> and some stream classes. So I think it should be easy to deprecate the 
>> Ok() version doing, more or less, the following steps:
>>
>>   1) s/.Ok(/.IsOk(
>>   2) s/->Ok(/->IsOk(
>>   3) s/::Ok/::IsOk
>>   4) s/bool Ok(/book IsOk(
>>
>>   5) add to wxGDIObject and wxStreamBase the following functions:
>>
>>       virtual bool IsOk() const = 0;
>>       wxDEPRECATE( bool Ok() const );
>>
>>      (assuming all wxGDIObject-, wxStreamBase-derived classes do have 
>> an IsOk() function)
>>
>>   6) implement the deprecated Ok() function in terms of IsOk()
>>
>>
>> if this approach reveals too simplistic (i.e. too many classes non 
>> wxGDIObject- or wxStreamBase-derived have Ok()), I think it shouldn't 
>> be too difficult to write a script which changes in the headers the:
>>
>>     bool Ok() const;
>>
>> occurrences into:
>>
>>     bool IsOk() const;
>>     wxDEPRECATE( bool Ok() const );
>>
>> and in a similar way the sources (adding a dummy impl for deprecated 
>> Ok())...
>>
>> is this a crazy idea?
> I would welcome consistency, but not the wxDEPRECATE keyword on 
> functions that are used potentially thousands of time in an application 
> - there would be huge numbers of warnings for a cosmetic change. In fact 
> perhaps Ok/IsOK should be made interchangeable in all classes, rather 
> than deprecating one or the other. 
right - this is ok to me (even if I think that all docs should be
modified to document only the "IsOk" functions - otherwise only the 
small set of people reading this thread would know about this change ;))...

I've posted a smart script which automates all the required changes...

Francesco







More information about the wx-dev mailing list