Do pure functions solve the "return const" problems?
Christopher Wright
dhasenan at gmail.com
Sun Apr 6 18:31:16 PDT 2008
Janice Caron wrote:
> On 05/04/2008, Christopher Wright <dhasenan at gmail.com> wrote:
>> 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.
>
> You're not getting this. If two values are being returned, the
> compiler can't just throw one of them away. In the general case, it
> doesn't have enough information to know what to do.
You're not getting this.
int f (out int i);
int x;
int y = f(x) + f(x);
This already works. Why couldn't pure functions do this? You can't tell
me. You aren't arguing. You are just stating that the compiler can't do
something that it already does. If the compiler supports memoization of
pure functions based on parameters, it could easily exclude out
parameters. If the compiler requires that all inputs to a pure function
be scope invariant, out parameters could be excluded from that requirement.
You come up with good ideas, but it happens every day that you argue
about someone else's idea without giving their point of view a
reasonable amount of thought. You assume that they are wrong and only
accept information that supports that conclusion. It is possible to
change your mind, but it would be nice if you tried arguing fairly more
often.
More information about the Digitalmars-d
mailing list