Thread overview
[Issue 808] New: using properties as lvalues
Jan 07, 2007
d-bugmail
Apr 02, 2009
d-bugmail
May 07, 2009
d-bugmail
May 31, 2012
Leandro Lucarella
May 31, 2012
Dmitry Olshansky
May 31, 2012
Vladimir Panteleev
May 31, 2012
Dmitry Olshansky
May 31, 2012
Jonathan M Davis
January 07, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=808

           Summary: using properties as lvalues
           Product: D
           Version: 0.178
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: www.digitalmars.com
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: thecybershadow@gmail.com


I've been wondering - what is actually preventing us to operate with properties like real lvalues? For example,

int[] array;
array.length++;      // Error: (array).length is not an lvalue
array.length += 2;   // Error: (array).length is not an lvalue

however,

array.length = array.length + 1; // works

Unless there's a fair reason of why this isn't viable, I'd suggest implementing this.


-- 

April 02, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=808





------- Comment #1 from baryluk@smp.if.uj.edu.pl  2009-04-02 08:49 -------
Assigment to properties is actually call to some method which actually do other
operations (like reallocation). I think that
   p op= x,
properties operations should be defined as
  p = p op x

Also for user defined properties (if both setter and getter is availble, so "lvalue-like" behaviour can be emulated in this way). Cases in which p += x, should be performed differently can always be emulated by using wrapper struct/class, which caries state and overloads opAddAssign. This cases are rear, but still possible. (usefull for some highly optimized codes, or synchronized/atomic changes, or loging actuall changes)



array.length *= 2;  is one of the most annoying :)


-- 

May 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=808


dsimcha@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ghaecker@idworld.net




------- Comment #2 from dsimcha@yahoo.com  2009-05-07 08:06 -------
*** Bug 2949 has been marked as a duplicate of this bug. ***


-- 

May 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=808


Leandro Lucarella <leandro.lucarella@sociomantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |leandro.lucarella@sociomant
                   |                            |ic.com
            Version|0.178                       |D2


--- Comment #3 from Leandro Lucarella <leandro.lucarella@sociomantic.com> 2012-05-31 04:36:03 PDT ---
This is a highly voted enhancement request but there is no "official" statement about it. Would be nice to have some "official" comment for votes with so many votes.

Is this intended to be implemented at all? Otherwise I guess is better to close it with WONTFIX to decrese bugzilla's "noise".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=808


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh@gmail.com


--- Comment #4 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-05-31 04:45:19 PDT ---
I'll fork the language if it's not fixed.

And of course I'll seduce the whole Russian communitiy to follow suit ;)

Seriously, it's important. I've hit it like 10+ time just today.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=808


Vladimir Panteleev <thecybershadow@gmail.com> changed:

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


--- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-05-31 04:46:16 PDT ---
The examples in my original post, as well as Witold's "array.length *= 2", work now.

This issue originally referred to built-in language properties, like .length. The @property kind of properties can be lvalues if the getter returns an lvalue - for example, @property ref int x() { return _x; }, or as Witold mentioned, using wrapper types.

I think we can consider this bug as resolved today.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=808



--- Comment #6 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-05-31 04:47:51 PDT ---
Thx Vladimir, I haven't tried ref return.
So silly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=808


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #7 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-05-31 08:37:19 PDT ---
And using ref with a property pretty much defeats its entire purpose, since setting it ends up completely bypassing the getter. We really need to be able to have stuff like prop++ work _without_ ref. But there's another enhancement request that's properly specific about that: issue# 8006

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