digitalmars.D - newCTFE Status June 2020
- Stefan Koch (16/16) Jun 08 2020 Hi Guys,
- kinke (4/15) Jun 08 2020 Allocation and pre-initialization of classes is handled by
- Stefan Koch (4/22) Jun 08 2020 Ah so bringing a class to the initial state, is done by
- rikki cattermole (7/9) Jun 08 2020 I wonder if you could CTFE it?
- Bastiaan Veelo (4/7) Jun 09 2020 Good job of staying current!
- Stefan Koch (2/10) Jun 09 2020 That's for "you" to decide.
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
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
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:Ah so bringing a class to the initial state, is done by _d_newclass. Yet another runtime function which CTFE has to re-implement.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
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
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
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:That's for "you" to decide.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