www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11235] New: Add analog of TypeTuple that does not auto-expand

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

           Summary: Add analog of TypeTuple that does not auto-expand
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: public dicebot.lv


--- Comment #0 from Dicebot <public dicebot.lv> 2013-10-12 14:23:58 PDT ---
This topic pops up frequently in D.learn when one needs to pass several
distinct TypeTuple's as template arguments. Auto-expansion behavior of existing
TypeTuple does not make it possible because two will be merged into single
argument list.

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


Dicebot <public dicebot.lv> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Dicebot <public dicebot.lv> 2013-10-12 14:26:27 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1633

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-12
14:34:46 PDT ---
Isn't this what http://dlang.org/phobos/std_typecons.html#.Tuple is for?

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



--- Comment #3 from Dicebot <public dicebot.lv> 2013-10-12 14:50:38 PDT ---
No, those are quite different. `std.typecons.Tuple` defines runtime tuple
(struct). It can be CTFE'ed of course, but it can't contain types (in TypeTuple
sense) or aliases (completely), only values and value meta-data.

Proposed `Group` acts exactly like `TypeTuple` but do not auto-expand.

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



--- Comment #4 from Dicebot <public dicebot.lv> 2013-10-12 14:52:15 PDT ---
If TypleTuple comparison would have been legal, one could say that `Group!(int,
double, foo).expand == TypeTuple!(int, double, foo)`

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



--- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-12
14:55:06 PDT ---
(In reply to comment #3)
 No, those are quite different. `std.typecons.Tuple` defines runtime tuple
 (struct). It can be CTFE'ed of course, but it can't contain types (in TypeTuple
 sense) or aliases (completely), only values and value meta-data.
 
 Proposed `Group` acts exactly like `TypeTuple` but do not auto-expand.
Right.. well with Group you end up having a third tuple kind. I think it's best that we wait for a language implementation of tuple syntax (see http://wiki.dlang.org/DIP32). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11235



--- Comment #6 from Dicebot <public dicebot.lv> 2013-10-12 15:05:25 PDT ---
It is not a 3d kind of tuple, it is just another syntax for existing TypeTuple.
Considering outcome of last tuple discussion threads any changes in that domain
won't come any time soon and this small addition allows to implement certain
algorithms right here and now.

I personally don't mind keeping it in "stdx" part of my projects but it is
mentioned quite frequently as a necessary feature [citation needed].

Also DIP32 addresses different issues and won't change the fact that both
expanding and non-expanding tuples are needed in different places.

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


David Nadlinger <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code klickverbot.at


--- Comment #7 from David Nadlinger <code klickverbot.at> 2013-10-12 15:45:59
PDT ---
I wonder whether it is worth adding this as an officially supported kind of
tuple, or if we should encourage making creative use of the current syntax to
keep the complexity low: (untested, just typed it up to illustrate the
principle of nesting templates)

---
template isEqual(T...) {
  template to(U...) {
    static if (T.length == U.length) {
      static if (T.length == 0) {
        enum to = true;
      } else {
        enum to = isSame!(T[0], U[0]) && isEqual!(T[1 .. $]).to!(U[1 .. $])
      }
    } else {
      enum to = false;
    }
  }
}

static assert(isEqual!(1, 2, 3).to!(1, 2, 3));
---

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



--- Comment #8 from Dicebot <public dicebot.lv> 2013-10-13 03:48:30 PDT ---
Main problem with nesting is that it does not allow algorithms with variadic
amount of tuples.

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