Reviving Phobos

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Tue Apr 11 17:49:55 UTC 2023


*whispers* https://github.com/Project-Sidero/basic_memory

Currently being working on: https://github.com/Project-Sidero/eventloop

However my stuff won't help you. I want more guarantees, not less. Yes 
it is -betterC, which only drives it harder. Since you don't want this 
to be valid D:

```d
MyRef myRef = ...;
auto mem = myRef.get;
myRef.destroy;
//use mem
```

Not only could that not segfault, but it could still have valid data in 
mem's memory. Which is a very scary possibility.

I gotta say what I've been able to build so far is very impressive. 
Having dmd build DLL's that look and feel like regular in binary code? 
(ok ignoring a few workarounds...). Along with supporting druntime in 
executable, with GC and druntime thread integration? Muhaha.



But as far as fibers are concerned? Kill them off. They are a target + 
platform + system C compiler ABI hack. They waste GC time scanning 
memory which has no valid data in it.

The solution should be coroutines. Superior in basically every way. But 
you need language assistance to make them nice. I.e. this is not the 
nice way to do it (but do-able):

```d
Coroutine myCoroutine() {
     static struct State {

     }

     enum Stages {
         Start,
         Second,
     }

     CoroutineBuilder!(State, Stages, int) builder;
     builder[Stages.Start] = (scope ref state) {
         //return builder.result(2);
         SystemHandle sysHandle;
         return builder.nextStage(Stages.Second).after(handle);
     };

     return builder.build();
}
```



In terms of Phobos itself, it just needs leadership. After all, how many 
years has it been since we found out that console support on Windows 
should NOT be done with C standard IO? Cos that would be an easy module 
to write up.


More information about the Digitalmars-d mailing list