newCTFE Status March 2018
Meta
jared771 at gmail.com
Sat Mar 31 05:36:06 UTC 2018
On Friday, 30 March 2018 at 19:48:02 UTC, Stefan Koch wrote:
> Hello Guys,
>
> I took a few days off over easter and I have very good news for
> you.
> The following code will now compile and execute correctly using
> newCTFE.
>
> ---
> class C
> {
> int i() {return 1;}
> }
>
> class D : C
> {
> override int i() {return 2;}
> float f() { return 1.0f; }
> }
>
> class E : D
> {
> override int i() {return 3;}
> override float f() { return 2.0f; }
> }
>
>
> int testClassStuff ()
> {
> C c1, c2, c3;
> D c4;
> c1 = new C();
> c2 = new D();
> c3 = new E();
>
> D e = new E();
> assert(cast(int)e.f() == 2);
>
> return c1.i + c2.i + c3.i;
> }
> static assert(testClassStuff == 1 + 2 + 3);
> ---
>
> In short this means that classes and virtual function calls
> work now.
> albeit currently only if you don't define your own constructor,
> which would currently get treated as normal function and
> therefore not set the vtbl pointer correctly.
>
> I'd also like to note that the vtbl handling is backend
> independent which means that you code your own backend for
> newCTFE without having to deal with the fact that vtbl and
> constructor stuff is going on.
> To you It's just load store and call. :)
>
> Have a nice easter.
>
> Stefan
newCTFE is looking very cool. Glad to see you're still working at
it.
More information about the Digitalmars-d
mailing list