Re: How exactly does Tuple work?

2020-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2020 at 13:57:08 UTC, Jan Hönig wrote: So it's like inheritance resolved at compile time. It's inheritance with virtual member functions without overhead. I am guessing only one alias works. And we use this, because struct can't do inheritance and interface is abstract.

Re: How exactly does Tuple work?

2020-11-08 Thread Jan Hönig via Digitalmars-d-learn
On Sunday, 8 November 2020 at 13:10:33 UTC, Adam D. Ruppe wrote: On Sunday, 8 November 2020 at 10:03:46 UTC, Jan Hönig wrote: Is there some recourse, which explains the `alias this`? If your object is used in a way that doesn't compile, the compiler will change `obj` to `obj.whatever_alias_t

Re: How exactly does Tuple work?

2020-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:03:46 UTC, Jan Hönig wrote: Is there some recourse, which explains the `alias this`? If your object is used in a way that doesn't compile, the compiler will change `obj` to `obj.whatever_alias_this_is` and try again. So say you have struct S { int a;

Re: How exactly does Tuple work?

2020-11-08 Thread Jan Hönig via Digitalmars-d-learn
On Saturday, 7 November 2020 at 18:31:18 UTC, Paul Backus wrote: Indexing and slicing are implemented with `alias expand this`, which causes `t[i]` to be lowered to `t.expand[i]`. Is there some recourse, which explains the `alias this`? I still don't understand what it does. I can't imagine

Re: How exactly does Tuple work?

2020-11-07 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 7 November 2020 at 18:02:26 UTC, Jan Hönig wrote: I have a simple question. How exactly does Tuple work? In detail, I am interested in expand and opSlice. A Tuple is a struct whose members are generated by type sequence instantiation: https://dlang.org/articles

How exactly does Tuple work?

2020-11-07 Thread Jan Hönig via Digitalmars-d-learn
I have a simple question. How exactly does Tuple work? In detail, I am interested in expand and opSlice. For expand, I have found the line: https://github.com/dlang/phobos/blob/master/std/typecons.d#L618 How does that work, where is the rest? What does it do? Similary I can access tuples