On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote:
Also I would to know what parts of Phobos are available there
(e.g. std.traits, std.typecons...).

There is no clear rule on which phobos packages work and which don't. It all depends on what underlying features the phobos package uses. Here is the list of what's not allowed in betterC:

- Garbage Collection
- TypeInfo and ModuleInfo
- Classes
- Built-in threading (e.g. core.thread)
- Dynamic arrays (though slices of static arrays work) and associative arrays
- Exceptions
- synchronized and core.sync
- Static module constructors or destructors

Generally anything meta/compile-time works. Packages like std.traits / std.meta / std.range / std.algorithm are not an issue. You would expect std.typecons.tuple to work as well, but it doesn't.

If you are doing ctfe, then you are in for a bummer. Because the same restrictions apply there as well. There is supposed to be a workaround by including the ctfe file in question via -I on the command line, but I could never make it work in dub.

If you encounter something that doesn't work, there are a couple of options. Sometimes the function you are trying to use is betterC compatible but is inside a package that isn't. Just extract it into a separate file. At other times it is because the struct has a toString method, or throws an exception. Again, copy the relevant part, rip out the toString method and/or replace the exception with an assert (of course, after you make sure the assert doesn't get triggered). There might also be the option to use @nogc exceptions (dip 1008), but I am not sure.

If all that isn't possible, you will have to rewrite the thing in question.

Reply via email to