Jump to page: 1 2
Thread overview
usable @nogc Exceptions with Mir Runtime
Oct 24, 2018
9il
Oct 24, 2018
jmh530
Oct 30, 2018
Oleg
Oct 31, 2018
9il
Oct 31, 2018
Uknown
Oct 31, 2018
bauss
Oct 31, 2018
9il
Nov 01, 2018
bauss
Nov 01, 2018
Atila Neves
Nov 02, 2018
9il
Nov 02, 2018
bauss
Nov 02, 2018
Manu
Nov 02, 2018
9il
Oct 31, 2018
Nathan S.
October 24, 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

October 24, 2018
On Wednesday, 24 October 2018 at 10:57:27 UTC, 9il wrote:
> 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
>
> [snip]

Cool. Keep up the good work.
October 30, 2018
Thanks for your work!

> 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!");
> }
>
> =======================

I don't understand why you choose C++ format style instead of D-style format?


October 31, 2018
On Tuesday, 30 October 2018 at 16:25:12 UTC, Oleg wrote:
> Thanks for your work!
>
>> 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!");
>> }
>>
>> =======================
>
> I don't understand why you choose C++ format style instead of D-style format?

The C++ format style is simpler to implement and it is much faster to run.
D's style came from C and Boost's format. Also, the C++ style is more low level then format strings, so they can be built on top of it.
October 31, 2018
On Wednesday, 31 October 2018 at 08:34:08 UTC, 9il wrote:
> The C++ format style is simpler to implement and it is much faster to run.
> D's style came from C and Boost's format. Also, the C++ style is more low level then format strings, so they can be built on top of it.

I think they meant why use the `<<` operator instead of the `~` operator?
October 31, 2018
On Wednesday, 31 October 2018 at 09:13:14 UTC, Uknown wrote:
> On Wednesday, 31 October 2018 at 08:34:08 UTC, 9il wrote:
>> The C++ format style is simpler to implement and it is much faster to run.
>> D's style came from C and Boost's format. Also, the C++ style is more low level then format strings, so they can be built on top of it.
>
> I think they meant why use the `<<` operator instead of the `~` operator?

This.

Please don't do that.
October 31, 2018
On Wednesday, 31 October 2018 at 09:13:14 UTC, Uknown wrote:
> On Wednesday, 31 October 2018 at 08:34:08 UTC, 9il wrote:
>> The C++ format style is simpler to implement and it is much faster to run.
>> D's style came from C and Boost's format. Also, the C++ style is more low level then format strings, so they can be built on top of it.
>
> I think they meant why use the `<<` operator instead of the `~` operator?

~ is used for string concatenation in D including string compile time constant concatenation.   It is better not to override it because both << and ~ can be used in the same expression.
October 31, 2018
On Wednesday, 24 October 2018 at 10:57:27 UTC, 9il wrote:
> Release v0.0.5 comes with
>
>  - mir.exception - @nogc MirException
>  - mir.format - @nogc formatting

Fantastic!
November 01, 2018
On Wednesday, 31 October 2018 at 13:56:56 UTC, 9il wrote:
> ~ is used for string concatenation in D including string compile time constant concatenation.   It is better not to override it because both << and ~ can be used in the same expression.

I see what your argument is now for it, BUT I would still have left it out because it's not idiomatic D and an alternative would have been better if you absolutely had to rely on ~ being used within the expression to combine both.

Ex.

try throw new MirException(stringBuf().append("Hi D", 2, "!", getData);

Would have been a much better approach similar to how write/writeln etc. work from std.stdio.
November 01, 2018
On Thursday, 1 November 2018 at 10:17:25 UTC, bauss wrote:
> On Wednesday, 31 October 2018 at 13:56:56 UTC, 9il wrote:
>> ~ is used for string concatenation in D including string compile time constant concatenation.   It is better not to override it because both << and ~ can be used in the same expression.
>
> I see what your argument is now for it, BUT I would still have left it out because it's not idiomatic D and an alternative would have been better if you absolutely had to rely on ~ being used within the expression to combine both.
>
> Ex.
>
> try throw new MirException(stringBuf().append("Hi D", 2, "!", getData);
>
> Would have been a much better approach similar to how write/writeln etc. work from std.stdio.

https://github.com/atilaneves/nogc/blob/ed4663558ceea1f5dc2634d6f01cc6ce6967adc1/tests/ut/exception.d#L49
« First   ‹ Prev
1 2