www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - newCTFE Status October 2021

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

I know I have been quiet about newCTFE for a while, mainly I have 
been focusing on other features which would make it more 
important, since a lot of the compile-time of certain companies 
is not spent in CTFE.

However recently I had the urge to fix an early design mistake in 
newCTFE.
And that was that newCTFE had no notion of a frame pointer.
Which made it impossible to easily take pointers of locals.

What newCTFE would do when it was asked to take the address of a 
local variable was to allocate space space on the heap.
Copy the local to the heap.
and then convert the local variable into a pointer to that heap 
location under the hood.

so
```D
int  x = 22;
int* y = &x;
```

would become:

```D
int  x = 22;
void* _mem_y = malloc(x.sizeof);
memcpy(mem_y, &x, z.sizeof);
int* y = cast(int*)mem_y,
&x = y; // this line represents nasty compiler magic
```

Now however I have the concept of a frame pointer, and things 
becomes much cleaner
The code above becomes:

```D
int  x = 22;
int* y = framePointer + OffsetFromFramePointer(x);
```

And no nasty syncing of different memory locations is required 
anymore ;)

Cheers,

Stefan
Oct 17 2021
next sibling parent Dylan Graham <dylan.graham2000 gmail.com> writes:
On Sunday, 17 October 2021 at 11:44:24 UTC, Stefan Koch wrote:
 Hi Guys,
Keep up the good work :)
Oct 17 2021
prev sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Sun, Oct 17, 2021 at 11:44:24AM +0000, Stefan Koch via Digitalmars-d wrote:
 Hi Guys,
 
 I know I have been quiet about newCTFE for a while, mainly I have been
 focusing on other features which would make it more important, since a lot
 of the compile-time of certain companies is not spent in CTFE.
Will newCTFE ever be merged? I've been looking forward to it for ... years. T -- Today's society is one of specialization: as you grow, you learn more and more about less and less. Eventually, you know everything about nothing.
Oct 20 2021
next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Thursday, 21 October 2021 at 02:11:44 UTC, H. S. Teoh wrote:
 On Sun, Oct 17, 2021 at 11:44:24AM +0000, Stefan Koch via 
 Digitalmars-d wrote:
 Hi Guys,
 
 I know I have been quiet about newCTFE for a while, mainly I 
 have been focusing on other features which would make it more 
 important, since a lot of the compile-time of certain 
 companies is not spent in CTFE.
Will newCTFE ever be merged? I've been looking forward to it for ... years. T
I think once it's ready it would be merged. It is fairly well tested. But maybe I am naive :)
Oct 20 2021
prev sibling parent bauss <jj_1337 live.dk> writes:
On Thursday, 21 October 2021 at 02:11:44 UTC, H. S. Teoh wrote:
 On Sun, Oct 17, 2021 at 11:44:24AM +0000, Stefan Koch via 
 Digitalmars-d wrote:
 Hi Guys,
 
 I know I have been quiet about newCTFE for a while, mainly I 
 have been focusing on other features which would make it more 
 important, since a lot of the compile-time of certain 
 companies is not spent in CTFE.
Will newCTFE ever be merged? I've been looking forward to it for ... years. T
Relatable, but that's often the case with most things in D. It takes years before you can use them and by that time most things have moved on, in which case the next new big thing has been started. D has ADHD.
Oct 21 2021