www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3608] New: Allow isExpression and templates to capture template parameters and FQN of template

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

           Summary: Allow isExpression and templates to capture template
                    parameters and FQN of template
           Product: D
           Version: future
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com



PST ---
Currently, there is no way to extract FQN of a template from an instantiation,
nor to get its parameters. This is not completely true, as one could parse its
stringof representation, but this is often not enough.

I therefore propose that the following syntax be allowed:

template foo( T : U!( V ), U, V... )

Thus, one could get the base template or parameters of an instantiation using
the following templates:

template BaseTemplate( T : U!( V ), U, V... ) {
  alias U BaseTemplate;
}
template TemplateParameters( T : U!( V ), U, V... ) {
  alias V TemplateParameters;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 11 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3608


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|future                      |D2
           Severity|enhancement                 |normal



PST ---
Judging by the recent resolution of bug 1714, this is not so much an
enhancement as a planned feature. Updating the syntax:

template foo( T : U!V, alias U, V... ) {
    //...
}

template BaseTemplate( T : U!( V ), alias U, V... ) {
    alias U BaseTemplate;
}
template TemplateParameters( T : U!( V ), alias U, V... ) {
    alias V TemplateParameters;
}

This may be a separate bug, as it concerns variadic parameter lists, something
bug 1714 fails to take into account.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



The patch in bug 5614 fixes some issues which seem similar to these.
But I'm not sure what these test cases are supposed to do. It seems to be an
attempt to use IFTI, but note that IFTI only applies to function templates. But
type deduction can also be used in is() expressions.

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




PST ---
I'm not sure what it is that confuses you. D allows constraints to be placed on
template parameters not only by means of template constraints, but also
isExpression-like patterns in the parameter list:

class A {}
class B : A {}

template isAnA( T : A ) {
    enum isAnA = true;
}

static assert( isAnA!B );

This also works for more complex type constraints:

template extractTupleArgs( T == Tuple!U, U... ) {
    alias U extractTupleArgs;
}

static assert( is( extractTupleArgs!( Tuple!int ) == int ) );

It does however not work for complex type constraints where the template is not
known:

template dissectTemplate( T == U!V, V... ) {
    alias U tmpl;
    alias V args;
}

And it is this last case I want covered.

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




PST ---

 template dissectTemplate( T == U!V, V... ) {
This should of course be template dissectTemplate( T == U!V, alias U, V... ) { -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 08 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3608


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/958

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




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

https://github.com/D-Programming-Language/dmd/commit/b327dd61e685c85adfdceef0767b4a456350667b
fix Issue 3608 - Allow isExpression and templates to capture template
parameters and FQN of template

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


Issue 1780 & 3608 & 8125 - Fix TypeInstance deduction problems

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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