Phobos, minimal runtime, -betterC compatibility documentation

Mike Franklin slavo5150 at yahoo.com
Wed Jun 6 04:04:25 UTC 2018


On Wednesday, 6 June 2018 at 01:34:13 UTC, Arun Chandrasekaran 
wrote:
> I'm more interested in no/minimal runtime[1] than -betterC for 
> my use cases.
>
> I think it will be good to have the document mention if the 
> function is supported without the druntime and/or with 
> -betterC. This documentation can be the module level or 
> function level. Is this possible and/or is it worth it?
>
> I understand that using druntime function with -betterC will 
> make the compiler throw error. But it will be good to know it 
> up front via doc if a function uses druntime or not.
>
> [1] https://dlang.org/changelog/2.079.0.html#minimal_runtime

What we actually need is to have the runtime itself to be 
well-documented.  In doing so, one would be able to see which 
features are implemented in the runtime and which features 
aren't, so what is and isn't supported in a "minimal runtime" 
would be self-evident.  In lew of that, however, I'll refer you 
to documentation "object", "core", and "rt" here:  
https://dlang.org/phobos/index.html.  Another good resource is 
https://wiki.dlang.org/Runtime_Hooks;  it's outdated, but still 
relevant.

Please also understand that one of the primary use cases for the 
"minimal runtime" changes in 2.079 is to allow users to port the 
runtime to a new platform incrementally in a pay-as-you-go 
fashion.  For that, you'll need to learn the details of the 
runtime anyway.

Prior to the changes in 2.079, you had to implement a large part 
of the runtime just to get a build, and most of that code would 
have never even been called from your program.  It was ridiculous 
and a major barrier to entry.  With 2.079, you can now implement 
just what you need incrementally, and that will make it much 
easier to learn the runtime.

What I'm trying to say, is the "minimal runtime" approach to 
using D is for those who wish to become runtime hackers, and are 
willing to study and experiment in order to learn how to take 
control of the runtime for themselves.  The reason the phrase 
"minimal runtime" is often used over "no runtime" is because it 
is up to you to decide which features of D to implement or not 
implement.

That being said, understand that -betterC does not link in the 
runtime, so anything not supported by -betterC will also not be 
supported by a bare runtime.  Therefore the documenation at 
https://dlang.org/spec/betterc.html is still relevant to the 
"minimal runtime" approach.    There are differences.  For 
example, I think -betterC forwards asserts to the C library, 
while a bare runtime would not.  But, the differences are few.

You're also welcome to ask questions.  I'm the one primarily 
responsible for those "minimal runtime" changes, and I'd be happy 
to help you if I can.

Mike

P.S. You're probably not going to have much success using Phobos 
in a "minimal runtime" scenario.  I'm exploring a way to get 
around that at https://github.com/JinShil/utiliD.


More information about the Digitalmars-d mailing list