[Issue 3008] Members of non-lvalues (rvalues) can be assigned to.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 30 14:00:31 PDT 2009


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





--- Comment #19 from Chad Joan <chadjoan at gmail.com>  2009-07-30 14:00:29 PDT ---
(In reply to comment #17)
> 
> You assume that the above is a bug and what I really wanted was to return a
> reference. Take another look while assuming that I actual do want return by
> value and the return by reference would be a bug.

I suppose what caught me is that it's easily possibly to write
GetProcessOutput() such that a ref return isn't a bug.  Just make sure the
reference doesn't point to an OutputHandle that's already in use.  I feel like
having a value return there is unnecessary.  

What I will give here though is that forbidding such function calls would
prevent the use of the caller's stack frame as a source of memory storage, but
only while using 1 liners to make the call.  It's complicated by the fact that
the function writer has to make the verbosity/efficiency tradeoff for the
caller.  

Then again...

ref OutputHandle GetProcessOutput( OutputHandle* buffer = null ) {...}

So it's possible to allow the caller to optionally provide stack space if they
want to, and still return ref.  If efficiency isn't an issue, it's still a
one-liner on the call side.

I'll admit that in the given circumstances this is not as clean.  Being able to
call off of rvalues allows both efficiency and brevity in this case.

I'd still rather have something that is a bit more verbose in some cases but
nearly impossible to unintentionally create bugs with.  It's not like actual
functionality is being removed.

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