On Tuesday, 19 August 2014 at 23:56:12 UTC, ketmar via Digitalmars-d wrote:
first: compilation speed. compiler can stop looking at function just
after the first 'return'.

No, it still has to check the other returns for errors anyway.

second: it's easier to human to determine the actual return type this
way.

Well, the return type is already the common type of all return paths, so you need to look anyway. This is just whether the return is by ref or by value. In any case, I'd argue correct semantics are preferable to a slight convenience when reading.

just add something like "if (0) return 42;" to foo(). compiler will eliminate dead code, but will use 'return 42' to determine function
return type.

That doesn't help at all. I want return by ref when possible, not always return by value. If I wanted return by value, I'd just return by value!!

Reply via email to