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


--- Comment #1 from Simen Kjaeraas <simen.kjaras gmail.com> 2010-10-01 15:25:37
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


--- Comment #2 from Trass3r <mrmocool gmx.de> 2010-10-29 03:52:29 PDT ---
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



--- Comment #3 from Simen Kjaeraas <simen.kjaras gmail.com> 2010-10-31 12:29:14
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 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


--- Comment #4 from Alex Khmara <alex.khmara gmail.com> 2011-01-01 22:22:42 PST
---
(In reply to comment #3)
 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