chaining chain Result and underlying object of chain
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 15 21:28:36 PDT 2015
On 9/14/15 11:30 AM, Ali Çehreli wrote:
> On 09/14/2015 08:01 AM, Laeeth Isharc wrote:
> > I was trying to use the same variable eg
> >
> > auto chain1 = chain("foo", "bar");
> > chain1 = chain(chain1, "baz");
> [...]
> > It may be that the type of chain1
> > and chain2 don't mix.
>
> Exactly.
>
> I was going to recommend using pragma(msg, typeof(chain1)) to see what
> they are but it looks like chain()'s return type is not templatized. (?)
>
> pragma(msg, typeof(chain1));
> pragma(msg, typeof(chain2));
>
> Prints
>
> Result
> Result
>
> instead of something like (hypothetical)
>
> ChainResult!(string, string)
> ChainResult!(ChainResult!(string, string), string)
>
> Ali
>
typeid is a bit better:
import std.range;
void main()
{
import std.stdio;
auto chain1 = chain("hi", "there");
auto chain2 = chain(chain1, "friend");
writeln(typeid(chain1));
writeln(typeid(chain2));
}
output:
std.range.chain!(string, string).chain.Result
std.range.chain!(Result, string).chain.Result
I still see that "Result" as a parameter for chain2.
I think the compiler should be better at printing these types at compile
time.
-Steve
More information about the Digitalmars-d-learn
mailing list