Do pure functions solve the "return const" problems?
Christopher Wright
dhasenan at gmail.com
Sat Apr 5 13:43:51 PDT 2008
Janice Caron wrote:
> On 05/04/2008, Christopher Wright <dhasenan at gmail.com> wrote:
>> That might be an argument for removing out parameters -- it looks like f(x)
>> + f(x) is the same as 2 * f(x). The compiler could tell the difference, so
>> there's no problem on that side. It could basically rewrite the pretty f(x)
>> + f(x) as the mess you recommended.
>
> I'm afraid it can't because + isn't defined for Tuple!(int,int). Even
> if the compiler could deduce what the declaration of g would have to
> be, it still couldn't write the body.
Yes, it could. You're explicitly telling it which return value you want
to use by which is listed at the function's return value rather than an
out parameter.
More information about the Digitalmars-d
mailing list