[Issue 1060] inout in arguments breaks the lvalueness of function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 13 15:31:08 PDT 2007


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


fvbommel at wxs.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #1 from fvbommel at wxs.nl  2007-03-13 17:30 -------
(In reply to comment #0)
> int[] foo(int[] arr){
>   return arr;
> }
> 
> int[] boo(inout int[] arr){
>   return arr;
> }
> 
> int[] arr = [1,2,3];
> 
> foo(foo(arr)); // ok
> boo(boo(arr)); // Error: boo(arr) is not an lvalue

Inout arguments don't "break" the lvalueness of a function. In fact, functions
aren't lvalues, nor are their return values (which is presumably what you
actually meant).
The problem isn't that lvalueness is "broken", it's that an inout argument
requires an lvalue to be passed and you're not doing it (in either case).
Because of that, the second case doesn't work. The first one works fine because
the parameter to foo isn't required to be an lvalue.

Summary: the problem is in your code, not in the compiler or language.

If this explanation isn't clear enough, please post a question about this in
digitalmars.D.learn about this. Maybe someone there can explain it better.


-- 



More information about the Digitalmars-d-bugs mailing list