On Saturday, 7 September 2024 at 13:28:39 UTC, Richard (Rikki) Andrew Cattermole wrote:
>On 08/09/2024 1:06 AM, Lance Bachmeier wrote:
>On Saturday, 7 September 2024 at 08:05:10 UTC, Kapendev wrote:
>BetterC is weird, but it does do something. If @nogc
were to be removed, BetterC could act as a replacement for those who want to avoid using the gc and enforce that at compile time.
How do you replace this code with BetterC? Answer: You don't.
import std;
void main() {
writeln(add(3, 4));
}
@nogc int add(int x, int y) { return x+y; }
The use cases of @nogc and BetterC are very different. With BetterC you lose classes, dynamic arrays, and associative arrays, among other things.
Just because you lose access to almost all of druntime and phobos does not mean you cannot replace almost everything.
module app;
import sidero.base.console;
@safe nothrow @nogc:
void main() {
writeln(add(3, 4)); // 7
}
int add(int x, int y) {
return x + y;
}
So far the only thing I haven't been able to find a solution for when needed is exceptions in terms of niceness.
On run.dlang.io:
onlineapp.d(1): Error: unable to read module `console`
onlineapp.d(1): Expected 'sidero/base/console.d' or 'sidero/base/console/package.d' in one of the following import paths:
import path[0] = /dlang/dmd/linux/bin64/../../src/phobos
import path[1] = /dlang/dmd/linux/bin64/../../src/druntime/import
Searching on code.dlang.org: Found 0 packages. So not much of a replacement.