Making AssertError a singleton
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 13 10:52:05 PST 2016
On 12/13/2016 01:23 AM, Shachar Shemesh wrote:
> On 12/12/16 23:02, Andrei Alexandrescu wrote:
>> Why am I not surprised :o).
>
> I'm not sure what to make of that comment.
Just jesting, and not always in style. Apologies. Let me restate the
factors at play here; admittedly the matter is a bit fuzzily defined at
the moment:
* A number of D libraries (Ilya's Mir being a prominent one) aim to
offer a C-level API that is shunning a relatively heavy runtime support
library. Mir makes use of D's cool compile-time introspection and such,
but avoids things like module information and the garbage collector. A
good way to go about it is compile with -betterC and not link druntime.
* Druntime has a simple charter: isolate the platform-dependent things
needed to get a D implementation going. However, its design predates a
bunch of great things done with templates. This makes for druntime to
miss many opportunities to be smaller, more modular, and faster.
* People have noticed that certain simple uses of D trigger calls into
druntime that are not quite justified. For example, assigning an array
of int to another array of int issues a call into a function that uses
dynamic introspection (!) to copy any array into any other array. A
template present in object.d would trivially do this using introspection
to boil down to memcpy.
* Generally reducing the footprint of druntime support amenities for
performing something with D is a good thing. Hence, assert() not
requiring the GC to be linked is good because it would allow folks who
don't link the GC at all to still use assert without needing to redefine it.
The community has been aware for a while that there's some good
opportunity to use modern techniques such as lowering and templates to
make druntime smaller, more modular, and actually more self-effacing.
Ilya brought this point strongly recently with a good use case, and
https://github.com/dlang/druntime/pull/1710 is a step in that direction.
Andrei
More information about the Digitalmars-d
mailing list