www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - newCTFE Status June 2020

reply Stefan Koch <uplink.coder googlemail.com> writes:
Hi Guys,

I've ported newCTFE to the latest "stable" release of DMD 2.092.0.

While trying to test newCTFE on some std.regex code to see if it 
would make a difference there, I noticed that default 
construction of classes is broken.

This is because dmd is a little funky and does not generate a 
default construction-function for you.
Rather it leaves you to build your own.
(As far as I can see anyways.)

Which I then documented on a new wiki page were all of my more 
surprising discoveries about dmd will land.

[https://wiki.dlang.org/Random_DMD_Facts]

This promoted me to clean up my assignment-to-field code which 
was duplicated for structs and classes.

More such cleanup passes will happen and hopefully bring the 
code-size of newCTFE down considerably.
Jun 08 2020
next sibling parent reply kinke <kinke gmx.net> writes:
On Monday, 8 June 2020 at 15:30:26 UTC, Stefan Koch wrote:
 This is because dmd is a little funky and does not generate a 
 default construction-function for you.
 Rather it leaves you to build your own.
 (As far as I can see anyways.)

 Which I then documented on a new wiki page were all of my more 
 surprising discoveries about dmd will land.

 [from the Wiki page]

 Will be represented as a `NewExp`
 To get the function that is being called you need to look at 
 the member `member` If that `FuncDeclaration` is null, this is 
 a call to the default constructor.
Allocation and pre-initialization of classes is handled by _d_newclass in druntime. If NewExp.member is null, it means that the class has no default ctor, so no ctor call is needed.
Jun 08 2020
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Monday, 8 June 2020 at 15:43:02 UTC, kinke wrote:
 On Monday, 8 June 2020 at 15:30:26 UTC, Stefan Koch wrote:
 This is because dmd is a little funky and does not generate a 
 default construction-function for you.
 Rather it leaves you to build your own.
 (As far as I can see anyways.)

 Which I then documented on a new wiki page were all of my more 
 surprising discoveries about dmd will land.

 [from the Wiki page]

 Will be represented as a `NewExp`
 To get the function that is being called you need to look at 
 the member `member` If that `FuncDeclaration` is null, this is 
 a call to the default constructor.
Allocation and pre-initialization of classes is handled by _d_newclass in druntime. If NewExp.member is null, it means that the class has no default ctor, so no ctor call is needed.
Ah so bringing a class to the initial state, is done by _d_newclass. Yet another runtime function which CTFE has to re-implement.
Jun 08 2020
parent rikki cattermole <rikki cattermole.co.nz> writes:
On 09/06/2020 9:07 AM, Stefan Koch wrote:
 Ah so bringing a class to the initial state, is done by _d_newclass.
 Yet another runtime function which CTFE has to re-implement.
I wonder if you could CTFE it? https://github.com/dlang/druntime/blob/2fa694319da397d72ab09cb336f3d588107278c1/src/rt/lifetime.d#L73 If only there was a way to get the init state of a class that didn't rely on TypeInfo (like a trait). Incidentally that would make extern(C++) classes work properly and easily in -betterC
Jun 08 2020
prev sibling parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Monday, 8 June 2020 at 15:30:26 UTC, Stefan Koch wrote:
 Hi Guys,

 I've ported newCTFE to the latest "stable" release of DMD 
 2.092.0.
Good job of staying current! (Are you sending a message with your use of quotes? ;-)) —Bastiaan.
Jun 09 2020
parent Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 9 June 2020 at 14:39:11 UTC, Bastiaan Veelo wrote:
 On Monday, 8 June 2020 at 15:30:26 UTC, Stefan Koch wrote:
 Hi Guys,

 I've ported newCTFE to the latest "stable" release of DMD 
 2.092.0.
Good job of staying current! (Are you sending a message with your use of quotes? ;-)) —Bastiaan.
That's for "you" to decide.
Jun 09 2020