I've got plenty to say, but here is the long and the short of it: Use Mecca.
On 07/09/18 19:44, Peter Alexander wrote:
3. It was really frustrating that I had to make the compiler happy
before I was able to run anything again. Due to point #1 I had to move
code around to restructure things and wanted to make sure everything
continued working before all GC allocations were removed.
mecca.lib.reflection has "as".
https://weka-io.github.io/mecca/docs/mecca/lib/reflection/as.html
Here is how you use it:
void fun() @nogc {
as!"@nogc"( some code that is not @nogc );
}
4. I used std.algorithm.topNCopy, which is not @nogc. The error just
says "cannot call non-@nogc function [...]". I know there are efforts to
make Phobos more @nogc friendly, but seeing this error is like hitting a
brick wall. I wouldn't expect topNCopy to use GC, but as a user, what do
I do with the error? Having to dig into Phobos source is unpleasant.
Should I file a bug? What if it is intentionally not @nogc for some
subtle reason? Do I rewrite topNCopy?
5. Sometimes I wanted to add writeln to my code to debug things, but
writeln is not @nogc, so I could not. I could have used printf in
hindsight, but was too frustrated to continue.
mecca.log has logging facilities that are @nogc.
Now, to be fair, they are not actually @nogc, as by default it uses
writeln. It is, however, annotated with @nogc, for precisely the reasons
you encountered.
Shachar