unnecessary OS redundancy in druntime

Sean Kelly via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 12 13:47:36 PST 2014


On Friday, 12 December 2014 at 15:47:09 UTC, Joakim wrote:
>
> It seems like pointless repetition and there are many more 
> examples of this, as I keep running into it when adding 
> bionic/Android support.  Martin suggested that it would be 
> useful to have a default case that asserts for an unsupported 
> OS, but many of these blocks don't have that either.
>
> Why not just declare them once for Posix and then specialize 
> for a particular OS later on when necessary

Because therein lies madness.


> as seems to have been done in these instances?

I could be convinced to allow required function prototypes to be
in version(Posix) blocks, but never data definitions.  And even
putting function prototypes in common version blocks risks link
errors.  I would *love* it if platforms that contained a header
actually implemented all of the functions required by a specific
tag (required, xopen, etc) when choosing any one from that tag,
but even this can't be relied upon.

In my C/C++ code I have compatibility modules that conditionally
implement missing functions based on the platform and libc
version, but this is so not fun.  Particularly when you're
targeting as many platform as D is trying to.  So really, you
should never see a version(Posix) block in core.sys.posix,
because it means that for some platform, compilation/linking will
fail.


> As can be seen from these links, druntime is not consistent in 
> how it's separating declarations for different OSs, sometimes 
> using the latter, more compact declarations, other times highly 
> redundant for no apparent reason.  If we can hash out how it 
> should be done, I'll submit a pull to fix it up.

It should all be redundant.  It makes for large files, but is
far easier to maintain and debug against than mixing everything
together.


More information about the Digitalmars-d mailing list