Do pure functions solve the "return const" problems?

Christopher Wright dhasenan at gmail.com
Thu Apr 10 16:56:07 PDT 2008


Janice Caron wrote:
> On 10/04/2008, Christopher Wright <dhasenan at gmail.com> wrote:
>>  Why? Why wouldn't that merely be undefined behavior when you add pure?
> 
> Part of the contract for purity is that the result *MUST* be
> independent of the order of evaluation of pure functions.
> 
> That meas, if D's "pure" keyword is intended to give us functional
> programming, then it's not going to let us have "out" parameters. The
> way to return values is through the return statement.

The results of these functions is independent of the order in which they 
are called. This would not be true with inout parameters. Of course, you 
can fake inout parameters with repeated arguments.

It should, however, suffice to say that such things are undefined 
behavior, as they currently are.



More information about the Digitalmars-d mailing list