Do pure functions solve the "return const" problems?

Janice Caron caron800 at googlemail.com
Thu Apr 3 04:48:14 PDT 2008


On 03/04/2008, Christopher Wright <dhasenan at gmail.com> wrote:
>  Pure functions cannot have out or ref parameters?

I'm only guessing, but I would guess no.

>  Out parameters should certainly be supported.

If I've understood this correctly, in pure functions, you don't return
anything via the parameters. Everything you return, you do through the
return statement.

That means, instead of

    void f(in int a, out float b, inout string s)
    {
        ...
    }

    f(a,b,s);

you'd do

    import std.typecons; // for Tuple

    pure Tuple!(float,string) f(int a, string s)
    {
    }

    auto t = f(a,s);
    b = t._0;
    s = t._1;



More information about the Digitalmars-d mailing list