CTFE and Wasm

Stefan Koch uplink.coder at googlemail.com
Sat Apr 30 09:48:22 UTC 2022


On Saturday, 30 April 2022 at 07:08:48 UTC, Ola Fosheim Grøstad 
wrote:
> I understand why both D and C++ users make a fuzz about CTFE, 
> it gives them a feeling of being able to extend the type system 
> or language in a way they are used to. However they are still 
> at wn disadvantage to more powerful languages that allow 
> construction of new types at runtime and do CTFE as an 
> optimization.
>
> Reason 1: compilation performance.
> Reason 2: poor debugging tooling.
>
> I'd say you don't have a proper CTFE solution until you can set 
> breakpoints in all functions and see what goes on.
>
> One possibility is to reuse WASM infrastructure by compiling 
> CTFE functions to WASM and use source maps for debugging.
>
> What do you think?

You could write a webasm backend for newCTFE.
That is actually what newCTFE was designed to support.
It translates the frontend AST into a simpler IR.
Which can then be more easily translated into WASM or LLVM or 
whatever.
I haven't rebased my branch in a while but if someone wants to 
work on it they should feel free fork it and do so.


More information about the Digitalmars-d mailing list