www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8148] New: properties and the ternary operator

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8148

           Summary: properties and the ternary operator
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mrmocool gmx.de



import std.datetime;
import std.stdio;

void main()
{
    Thing t;
    t.vPosition = (Clock.currStdTime % 2 == 0) ? Vec(2, 2) : Vec(3, 3);
    Vec v = t.vPosition;

    writeln("%d %d\n", v.x, v.y);
}

struct Vec
{
    int x;
    int y;
}

struct Thing
{
     property Vec vPosition() { return mPosition; }
     property Vec vPosition( const ref Vec value ) { return mPosition = value;
}

private:
    Vec mPosition;
}

$ dmd test.d 
test.d(7): Error: not a property t.vPosition

t.vPosition = Vec(3,3); works.

I think either both has to work or none.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8148


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED



Because struct literals are no longer lvalues, t.vPosition = Vec(3,3); doesn't
work either.

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