[Issue 6442] Allow for passing values with the 'ref' keyword

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 7 00:22:57 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6442



--- Comment #17 from wfunction at hotmail.com 2011-08-07 00:22:55 PDT ---
> const, immutable, shared etc. have a large effect on the semantics of a program. The compiler gives you additional guarantees as a result. e.g. immutable variables can't be altered and non-shared can't be affected by other threads.

Right.

> However, the situation with your feature request is much different.

Wrong.

Consider a piece of code like this:

    bool process(string key, out string value);
    ...
    string value;
    if (process(key, value))
        ...

Now imagine that, later down the road, I decide to make 'value' actually become
a 'ref' parameter, because I want to use its initial value to, for example, set
the default value of the environment variable somewhere else, even though I
originally only wrote to it.

The code that calls process() is broken.

Wouldn't it be nice to have an 'out' indicator on 'value', which would give a
compile error when the code changes?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list