Generality creep

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Mar 28 19:12:40 UTC 2019


On Thu, Mar 28, 2019 at 02:47:49PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
[...]
> Oh, and druntime must go.
> 
> The whole distinction between the runtime library and the standard
> library is clowny and has more to do with poorly ported tradition from
> other languages, than with anything else.

OK, *this* is going to be an even more drastic change.  So what happens
with the current compiler bindings to druntime?


> We need one standard library that is entirely pay-as-you-go (e.g.
> empty main() means no library file is ever needed for linking) and
> that offers an opt-in continuum.

That would be a very welcome change.

But I'd also have to warn that this may not be as trivial as you appear
to think.  There's a lot of deep-seated stuff in the compiler that
heavily ties it to the current druntime implementation.  Replacing all
of that is going to be a non-trivial feat.

The TypeInfo stuff, for one thing, will take some work to reach your
vision of a completely opt-in library.  Currently, trying to link
without druntime will cause a bunch of errors related to missing
TypeInfo's.  It *is* clowny, I'll give you that -- the compiler really
should not be emitting this stuff (or should be using weak symbols for
it) unless it's actually *used* by the user code.

Similarly, we should get rid of the implicit Monitor field in classes --
useless deadweight unless the user code needs synchronized classes.

Or the GC initialization in rt_init / rt_term.  Or, for that matter, the
initialization code that packages command-line arguments into a string[]
before invoking Dmain.  To achieve not linking any library for empty
main() the compiler would have to stop emitting calls to rt_init /
rt_term unless the program uses the GC.  And it'd have to emit main() as
`main` rather than `Dmain` if you're going to want to omit the current
standard initialization code.  (And don't forget the need to invoke
module static ctors -- in topological order, which requires some amount
of code to get right.)

And so on and so forth.

IOW, what we're looking at here is nothing short of what essentially
boils down to D3.  I applaud this direction, but let's not kid ourselves
that this is going to happen overnight.


T

-- 
Music critic: "That's an imitation fugue!"


More information about the Digitalmars-d mailing list