On Mon, 2005-11-28 at 12:40 +1030, Glen Turner wrote: > Tess Snider wrote: > > In C, I guess you > > could return an arbitrary negative value, since the function should > > never be returning a negative value on good input data. > > Hi Tess, > > This is called a "pinball API" since the result to someone > who doesn't recognise that the return value needs to be > tested is essentially random. Much better to make that > requirement explicit in the API. > > bool factorial(unsigned int *n);
This makes this unusable with a const variable. Admittedly avoiding pinballs API's is interesting (though I *much* prefer just using CExcept if I want to ensure the caller can't forget to handle an error :)) - because exceptions let you write chainable functions. But thats a different topic .. I'd want something like: bool factory(unsigned int * const result, unsigned int * const * n); which lets me use it with a const-correct environment. Rob -- GPG key available at: <http://www.robertcollins.net/keys.txt>.
signature.asc
Description: This is a digitally signed message part
-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
