How can we make it easier to experiment with the compiler

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue May 25 13:11:17 UTC 2021


On Tuesday, 25 May 2021 at 12:47:53 UTC, Ola Fosheim Grøstad 
wrote:
> Parts that are considered unstable need to be encapsulated and 
> provide interfaces so that people can build on those interfaces 
> instead of making change hard by tying more stuff to the code 
> that you want to replace.

The key point here is designing new and better interfaces. You 
cannot refactor yourself into heaven with no redesign.

But it does not have to be disruptive. As an example, let's 
pretend we want a new AST and a new IR. Here is a non-disruptive 
sequence:

1. Write new AST and translation to old AST. Not disruptive.

2. Write translation from old AST to new IR, and encourge 
backends to transition. Not disruptive.

3. Transition to new IR, by making old AST private. Backends are 
ready. Not disruptive.

4. Move passes one by one to new IR. Not disruptive.

5. Write translation from new AST to new IR. Done.

You don't want to document your old interface, because you don't 
want people to depend on it. You want to document your new 
interface and encourage people to transition. Then you eventually 
can make the old interface private and can in peace replace the 
old parts.





More information about the Digitalmars-d mailing list