[Issue 3167] Passing result of a function call as ref argument no longer works

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 15 03:38:45 PDT 2009


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





--- Comment #8 from Bill Baxter <wbaxter at gmail.com>  2009-08-15 03:38:43 PDT ---
(In reply to comment #7)
> What if X is replaced by int? Should that work? I think it's a problem.

Well, probably not, because 'int' is not a large struct.  So the only reason to
pass it 'ref' would be if you wanted to modify it.

But then you get into a case like

X add(X)(ref X a, ref X b) {
    return a + b;
}

where foo takes ref in order to accept large value types without inordinate
amounts of copying.  But someone might want to pass int too.  It would be odd
if that code worked for certain size arguments but not others.

If you're going to change the D1 behavior anyway, the best solution in my
opinion would be to give D1 a way to specify that you want to pass by reference
for efficiency, but don't want to modify the value.  Give it a weak form of
const parameters like C has.

-- 
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