D is nice whats really wrong with gc??

Bkoie bkoie049 at gmail.com
Mon Dec 18 16:44:11 UTC 2023


just look at this i know this is overdesign im just trying to get 
a visual on how a api can be design im still new though but the 
fact you can build an api like this and it not break it is 
amazing.

but what is with these ppl and the gc?
just dont allocate new memory or invoke,
you can use scopes to temporry do stuff on immutable slices that 
will auto clean up
the list goes on

and you dont need to use pointers at all.......!!

i honesty see nothing wrong with gc,

ofc d has some downsides,
docs not very good compare to some other lang.
ide support not great but it works sometimes
i use helix and lapce and maybe sometimes intellj
it works better in helix though.
and of d is missing some minor libraries

```
import std.stdio: writeln, readln;
auto struct Game
{
     string title;
     private Board _board;
     private const(Player)[] _players;
     final auto load(T)(T any) {
         static if (is(T == Player)) {
             _pushPlayer(any);
         }
         return this;
     };
     final auto play() {assert(_isPlayersFull, "require players is 
2 consider removing"); "playing the game".writeln;};
     final auto _end() {};
     auto _currentPlayers() const {return _players.length;}
     enum _playerLimit = 2;
     auto _isPlayersFull() const {return _currentPlayers == 
_playerLimit;}
     import std.format: format;
     auto _pushPlayer(T: Player)(T any) {
         if (_isPlayersFull) assert(false, "require %s 
players".format(_playerLimit));
         _players.reserve(_playerLimit);
         _players ~= any;
         }
}
private struct Board {}
enum symbol {none, x, o}
private struct Player {const(string) _name; symbol _hand; 
@disable this(); public this(in string n) {_name = n;}}
alias game = Game;
alias player = Player;
alias board = Board;
auto main()
{
     import std.string: strip;
     game()
     .load(player(readln().strip))
     // .matchmake
     .load(player(readln().strip))
     .play;
}
```


More information about the Digitalmars-d-learn mailing list