Proposal: Use UErrorCode& rather than UErrorCode* in C++ API [clarification]

Alan S Liu <[email protected]> Fri, 26 Mar 2004 11:50:43 -0800
Newsgroups gmane.comp.lib.icu.general
Message-ID <OF70B148B0.A4929AA5-ON88256E63.006C5D94-88256E63.006D04B3@us.ibm.com>
[Clarification: the proposed change is listed under "Proposal".  The 
"ALTERNATIVE" is noted for discussion only.  It will not be pursued unless 
someone successfully argues for it.]

__________________

Affects ICU4C 3.0

Background:  C++ API, by convention, takes a UErrorCode& parameter.  C API 
takes a UErrorCode*.

  class Foo {
    int32_t getBar(UErrorCode& ec);
  };

  int32_t ufoo_getBar(UErrorCode* ec);

Problem:  Some C++ API has been written to take a UErrorCode* parameter. 
This is probably unintentional.  While this works, it makes the API 
inconsistent and makes C++ client code less idiomatic.  Real example, in 
Formattable:

    /**
     * Gets the double value of this object.
     * @draft ICU 2.8
     */ 
    double getDouble(UErrorCode* status) const;

Proposal:  Fix such API, if it is @draft, by making the UErrorCode 
parameter a *reference*.  For example:

    /**
     * Gets the double value of this object.
     * @draft ICU 3.0
     */ 
    double getDouble(UErrorCode& status) const;

If the API in question is @stable, add a parallel API, and deprecate the 
existing API:

    /**
     * @stable ICU 2.0
     */ 
    int32_t         getLong(UErrorCode* status) const;

Becomes:

    /**
     * @deprecated ICU 3.0 use getLong(UErrorCode&)
     */ 
    int32_t         getLong(UErrorCode* status) const;

    /**
     * @draft ICU 3.0
     */ 
    int32_t         getLong(UErrorCode& status) const;

ALTERNATIVE:  If the API in question is @draft, fix it.  But for @stable 
API, throw up our hands and let it be -- "not worth it."

[Alan S Liu/San Jose/IBM@IBMUS; [email protected];; IBM Globalization; 
5600 Cottle Road; San Jose, CA 95193;; (408) 256-3155]