auto return for some recursive functions in C++11

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 14 15:23:30 PST 2015


On Wed, 14 Jan 2015 23:07:57 +0000
bearophile via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> ketmar:
> 
> > the spec says that return type for `auto` function is taken
> > from the first `return` operator parser met. so for the
> > second `return` the return type is already known.
> 
> Do you mean the C++14 spec or the D spec?
D spec. i'm not really interested in C++ progress, and certainly not
that much that i'll read any of it's specs.

> The D specs I see are (from: http://dlang.org/function.html ):
> 
> 
> > Auto Functions
> > 
> > Auto functions have their return type inferred from any
> > ReturnStatements in the function body.
> > 
> > An auto function is declared without a return type. If it does 
> > not
> > already have a storage class, use the auto storage class.
> > 
> > If there are multiple ReturnStatements, the types of them must 
> > be
> > implicitly convertible to a common type. If there are no
> > ReturnStatements, the return type is inferred to be void.
i bet that i read somewhere in specs that return type for `auto`
function is defined by first `return` parser sees. yet strangely i
can't find it right now. maybe that was changed recently, but i'm
almost sure that this is not false memory of mine.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150115/41324eda/attachment.sig>


More information about the Digitalmars-d mailing list