www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 620] New: Can't use property syntax with a template function

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

           Summary: Can't use property syntax with a template function
           Product: D
           Version: 0.175
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


I'd like to call this a bug, but I can't find any place in the spec that states
this should work.  However it seems logical that it would work given that the
property magic is just syntactic sugar that treats foo=x as a regular function
call foo(x).  

---------------
int g_value;

void valuef(int v) {  g_value = v; }

void valuet(T)(T v) { g_value = v; }

void main()
{
    valuef = 42; // ok
    valuet = 42; // Error: valuet is not an lvalue
                 // Error: cannot implicitly convert expression (42) of type
int to void
}


-- 
Nov 30 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras gmail.com



PDT ---
Could we please get this one fixed? Especially now with opDispatch, this is a
painful one.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool gmx.de



Yeah opDispatch could be used for vector swizzling setters.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 29 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620




PDT ---
Some hacking about showed me that opDispatch has a workaround for this problem,
by using a two-layer approach:

template opDispatch( string name ) {
    auto opDispatch( T... )( T args ) {
        // Do something!
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 31 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |bugzilla digitalmars.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 26 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Alex Khmara <alex.khmara gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex.khmara gmail.com



---

 Some hacking about showed me that opDispatch has a workaround for this problem,
 by using a two-layer approach:
 
 template opDispatch( string name ) {
     auto opDispatch( T... )( T args ) {
         // Do something!
     }
 }
This workaroung is only partial. This code produces "Error: s.opDispatch(T...) has no value". import std.stdio; struct S { template opDispatch( string name ) { string opDispatch( T... )( T args ) { return "bar"; } } } void main() { S s; string str = s.foo; } Same if I try "auto opDispatch" instead of "string". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 01 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |k.hara.pg gmail.com



I think this is not enhancement at least D2.
opDispatch for property syntax needs fixing this issue.

struct S
{
    template opDispatch(string name)
    {
         property int opDispatch(A...)(A args)
        {
          static if (args.length)
            return args[0];
          else
            return 0;
        }
    }
}
void main()
{
    S s;
    s.prop == 0;  // Error: s.opDispatch(A...) has no value
}

I have posted D2 patch.
https://github.com/D-Programming-Language/dmd/pull/280

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 29 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8bc639fb00cab9002b91a1d900ddd72f56f993a4


Issue 620 - Can't use property syntax with a template function

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 26 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|0.175                       |D1



17:12:27 PST ---
Fixed for D2.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 26 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=620


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
            Version|D1                          |D2
         Resolution|                            |FIXED



Closing since fixed on D2.

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