usable @nogc Exceptions with Mir Runtime

9il ilyayaroshenko at gmail.com
Wed Oct 24 10:57:27 UTC 2018


Hello

Mir Runtime [1] is Dlang @nogc runtime infrastructure for a 
simple, slim, and fast code. It is based on Mir Core [2] and 
compatible with Mir Algorithm [3] >=v3.0.0-alpha-dev.

Mir Runtime should be used with flags -dip1000, -dip1008 and 
optionally -dip25.

Release v0.0.5 comes with

  - mir.exception - @nogc MirException
  - mir.format - @nogc formatting

Mir Runtime uses a combination of DIP1000 [4] and DIP1008 [5].

Example
=======================
///
@safe pure nothrow @nogc
unittest
{
     import mir.exception;
     import mir.format;
     try throw new MirException(stringBuf() << "Hi D" << 2 << "!" 
<< getData);
     catch(Exception e) assert(e.msg == "Hi D2!");
}

=======================

If the message is non-scope string MirException constructor uses 
the message data itself (zero-copy).
If the message is scope const array of char with the size no 
greater then 447 bytes, MirException constructor uses local 
buffer preallocated by DRuntime, otherwise, MirException 
allocates memory using C's malloc.

Knows Issues:
  - DRuntime Issue 19317 [6] cause memory leaks for messages that 
have a size greater than 447 bytes.

This work has been sponsored by Symmetry Investments [7] and 
Kaleidic Associates [8].

1. https://github.com/libmir/mir-runtime
2. https://github.com/libmir/mir-core
3. https://github.com/libmir/mir-algorithm
4. https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md
5. https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md
6. https://issues.dlang.org/show_bug.cgi?id=19317
7. http://symmetryinvestments.com/
8. http://github.com/kaleidicassociates

Best regards,
Ilya Yaroshenko



More information about the Digitalmars-d-announce mailing list