On Friday, 16 June 2017 at 08:34:21 UTC, Biotronic wrote:
On Thursday, 15 June 2017 at 18:49:58 UTC, Jesse Phillips wrote:
wrap!IDuck
Ah, so it does exist in Phobos. I thought it should be there,
but didn't find it. Thanks!
--
Biotronic
Yeah, when Andrei introduced the wrap function I w
On Thursday, 15 June 2017 at 18:49:58 UTC, Jesse Phillips wrote:
wrap!IDuck
Ah, so it does exist in Phobos. I thought it should be there, but
didn't find it. Thanks!
--
Biotronic
On Wednesday, 14 June 2017 at 09:34:27 UTC, Balagopal Komarath
wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
You question was answered, but you can do this:
--
interface IDuck
{
void quack
On Thursday, 15 June 2017 at 07:12:56 UTC, Biotronic wrote:
Here however, is a solution that works for simple examples.
This is awesome. Very generic. Thanks.
On Wednesday, 14 June 2017 at 09:34:27 UTC, Balagopal Komarath
wrote:
void main()
{
Test!Duck d;
}
As has been pointed out at length by others here, it's simply not
how alias this is intended to work. I do see some arguments in
favor of working that way, but I'm not sure what's the ri
On Wednesday, 14 June 2017 at 22:29:08 UTC, Balagopal Komarath
wrote:
On Wednesday, 14 June 2017 at 21:04:55 UTC, basile b. wrote:
The way to do that in D is with mixins:
That is an interesting solution.
However, my original goal was to figure out whether one can
make struct types behave pol
On Wednesday, 14 June 2017 at 21:04:55 UTC, basile b. wrote:
The way to do that in D is with mixins:
That is an interesting solution.
However, my original goal was to figure out whether one can make
struct types behave polymorphically (Which is not mentioned in my
original question). I know
On Wednesday, 14 June 2017 at 09:34:27 UTC, Balagopal Komarath
wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
import std.stdio;
interface IDuck
{
void quack();
}
class Test(T) : IDuck
{
T data;
alias data thi
Balagopal Komarath wrote:
On Wednesday, 14 June 2017 at 11:40:02 UTC, ketmar wrote:
interfaces *require* a full-featured class, with VMT, and some hidden
pointers to support hidden interface machinery.
I don't think that is the problem here. The type Test!Duck is a class and
that type is the
On 6/14/17 5:34 AM, Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
import std.stdio;
interface IDuck
{
void quack();
}
class Test(T) : IDuck
{
T data;
alias data this;
}
struct Duck
{
v
On Wednesday, 14 June 2017 at 12:35:05 UTC, Mike B Johnson wrote:
void main()
{
Test!Duck d;
d.quack();
}
which, unfortunately causes a segmentation fault ;)
I think that is because you are not initializing d using new
Test!Duck();
On Wednesday, 14 June 2017 at 11:40:02 UTC, ketmar wrote:
interfaces *require* a full-featured class, with VMT, and some
hidden pointers to support hidden interface machinery.
I don't think that is the problem here. The type Test!Duck is a
class and that type is the one implementing the interf
Mike B Johnson wrote:
I don't think it has to do with pasting code.
d.Quack() is well defined through the alias. Inheritance requires that a
Quack() exists, and it does, through the alias.
The compiler could easily create an implementation wrapper that uses the
alias this.
this is called
On Wednesday, 14 June 2017 at 09:41:49 UTC, ketmar wrote:
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inheritance. no, `quack` is NOT
Balagopal Komarath wrote:
On Wednesday, 14 June 2017 at 09:41:49 UTC, ketmar wrote:
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inh
On Wednesday, 14 June 2017 at 09:41:49 UTC, ketmar wrote:
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack()
method but the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inheritance. no, `quack` is NOT
Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
'cause `alias this` is *not* a tool that can be used to emulate
inheritance. no, `quack` is NOT impemented. `alias this` won't
automagically paste the co
17 matches
Mail list logo