Re: usable @nogc Exceptions with Mir Runtime

2018-11-02 Thread 9il via Digitalmars-d-announce

On Friday, 2 November 2018 at 07:00:49 UTC, Manu wrote:
On Tue, Oct 30, 2018 at 9:30 AM Oleg via Digitalmars-d-announce 
 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?


Perhaps this is a stupid question... but there's clearly `new
MirException` right there in that code.
How is this @nogc?


The code requires -dip1008 flag. Take a look into the DIP 
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md


Re: usable @nogc Exceptions with Mir Runtime

2018-11-02 Thread Manu via Digitalmars-d-announce
On Tue, Oct 30, 2018 at 9:30 AM Oleg via Digitalmars-d-announce
 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?

Perhaps this is a stupid question... but there's clearly `new
MirException` right there in that code.
How is this @nogc?


Re: usable @nogc Exceptions with Mir Runtime

2018-11-02 Thread bauss via Digitalmars-d-announce

On Friday, 2 November 2018 at 05:21:07 UTC, 9il wrote:

On Thursday, 1 November 2018 at 10:17:25 UTC, bauss wrote:

[...]


Well, added at v0.0.8 [1].

Mir Runtime formatting and exceptions are CTFE-able if a msg 
fits into a local buffer and support user-defined types 
formatting. Note, that toString function must be scope const.


mir.parse was added in v0.0.7. Currently, only integer types 
are supported.


1. https://github.com/libmir/mir-runtime/pull/2


Thanks!


Re: usable @nogc Exceptions with Mir Runtime

2018-11-01 Thread 9il via Digitalmars-d-announce

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.


Well, added at v0.0.8 [1].

Mir Runtime formatting and exceptions are CTFE-able if a msg fits 
into a local buffer and support user-defined types formatting. 
Note, that toString function must be scope const.


mir.parse was added in v0.0.7. Currently, only integer types are 
supported.


1. https://github.com/libmir/mir-runtime/pull/2


Re: usable @nogc Exceptions with Mir Runtime

2018-11-01 Thread Atila Neves via Digitalmars-d-announce

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


Re: usable @nogc Exceptions with Mir Runtime

2018-11-01 Thread bauss via Digitalmars-d-announce

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.


Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread Nathan S. via Digitalmars-d-announce

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!


Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread 9il via Digitalmars-d-announce

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.


Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread bauss via Digitalmars-d-announce

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.


Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread Uknown via Digitalmars-d-announce

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?


Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread 9il via Digitalmars-d-announce

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.


Re: usable @nogc Exceptions with Mir Runtime

2018-10-30 Thread Oleg via Digitalmars-d-announce

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?