DIP54 : revamp of Phobos tuple types
Jakob Ovrum
jakobovrum at gmail.com
Tue Dec 24 02:54:48 PST 2013
On Tuesday, 24 December 2013 at 10:30:47 UTC, Dmitry Olshansky
wrote:
> As long as algorithms that operate say on 2 lists expect
> arguments to have '.expand' we'd be in a good shape just
> providing a `packList` or some such together with `list`.
I think so too. Of course, it is predicated on the fact that such
algorithms are added to Phobos. Note that when an algorithm
always expects 2 lists we can use nested templates instead, which
has some benefits.
The issue, of course, is that this proposal suggests having only
`packList` and changing all list algorithms to expect packed
lists, which I think (and have elaborated upon) is a nasty case
of fighting the language for no benefit, but for serious code
breakage and lots of extra code on lines that tend to be long
already[1].
> It would even work out of the box with current user-defined
> pack types if they have .expand.
Right, std.typecons.Tuple happens to be one such type.
[1] It's not the case that we can simply search and replace
`TypeTuple!(...)` => `TemplateArgumentList!(...).expand` and call
it a day; consider code like:
---
auto fun(Ranges...)(Ranges ranges)
if (!is(CommonType!(staticMap!(ElementType, Ranges)) == void)
{
...
}
---
If list algorithms are changed to receive packed list, the
`Ranges` argument to `staticMap` must be changed to
`TemplateArgumentList!Ranges`.
More information about the Digitalmars-d
mailing list