Re: Coding style survey

From: Richard Bos (rlb_at_hoekstra-uitgeverij.nl)
Date: 01/28/04


Date: Wed, 28 Jan 2004 14:53:08 GMT


"Malcolm" <malcolm@55bank.freeserve.co.uk> wrote:

>
> "Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message
> > > c), return is not a function. Though you want to ask why you are
> > > returning the return value from another function directly - this is
> > > unusual.
> >
> > Not at all. The function containing the return statement could be a
> > function which prepares the data for foo().
> >
> So there are exceptions. As a rule of thumb, however, if a function calls
> another function that returns a value, then the caller is the appropriate
> level to process that value - not simply to return it to a higher level.

Any reasons for that statement?

> If you need to prepare data for foo() then that would be an indication that
> foo() is badly written.

Nonsense. Look at the example I gave: it could easily be an indication
that foo() can work on any data, and the calling function uses it to
work on specific data.

Richard



Relevant Pages

  • Re: Coding style survey
    ... > function which prepares the data for foo(). ... level to process that value - not simply to return it to a higher level. ... Just an indication, mind you, there might be some ...
    (comp.lang.c)
  • Re: Coding style survey
    ... >> function which prepares the data for foo(). ... >level to process that value - not simply to return it to a higher level. ... Just an indication, mind you, there might be some ... There are many useful and valid reasons to return foo. ...
    (comp.lang.c)
  • Re: Function Returning a local object???
    ... because I can imagine the return value of foo() ... calling function) using the copy-constructor, ... The calling function usually does something with this object, ... The compiler is allowed to optimise all this, ...
    (comp.lang.cpp)
  • Re: Simple question
    ... Ivan Leo Puoti wrote: ... > What I return a double or float value from a function, ... > part makes it to the calling function. ... > foo from main, and in function foo there is a variable called a, and ...
    (comp.lang.c)
  • Re: Simple question
    ... Ivan Leo Puoti wrote: ... > part makes it to the calling function. ... > foo from main, and in function foo there is a variable called a, and ... Richard ...
    (comp.lang.c)