Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
June 08, 2020 newCTFE Status June 2020 | ||||
---|---|---|---|---|
| ||||
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. |
June 08, 2020 Re: newCTFE Status June 2020 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | 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.
|
June 08, 2020 Re: newCTFE Status June 2020 | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | 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.
|
June 09, 2020 Re: newCTFE Status June 2020 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | 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 |
June 09, 2020 Re: newCTFE Status June 2020 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | 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.
|
June 09, 2020 Re: newCTFE Status June 2020 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bastiaan Veelo | 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.
|
Copyright © 1999-2021 by the D Language Foundation