Re: Default-valued nothrow @nogc std.conv:to

2017-04-23 Thread crimaniak via Digitalmars-d
On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: Have anyone tried to implement a variant of `std.conv.to` that can be `nothrow @nogc` if the exception handling is replaced by an extra second parameter (`defaultValue`) returned iff the call to `to` throws? There is common ifThrown

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Stanislav Blinov via Digitalmars-d
On Saturday, 22 April 2017 at 12:16:19 UTC, Nordlöw wrote: On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: If I get this to work, I'm gonna try pushing it into std.conv. Another bit to pick on is the return value. auto x = toWithDefault!int("1", 0.0f); typeof(x) will be float even

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Stanislav Blinov via Digitalmars-d
On Saturday, 22 April 2017 at 18:26:56 UTC, Dmitry Olshansky wrote: On 4/22/17 6:57 PM, Stanislav Blinov wrote: On Saturday, 22 April 2017 at 16:41:00 UTC, Nordlöw wrote: If defaultValue is not lazy, it's potentially wasteful. What do you mean with "potentially wasteful"? Excess calls to

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Dmitry Olshansky via Digitalmars-d
On 4/22/17 6:57 PM, Stanislav Blinov wrote: On Saturday, 22 April 2017 at 16:41:00 UTC, Nordlöw wrote: If defaultValue is not lazy, it's potentially wasteful. What do you mean with "potentially wasteful"? Excess calls to copy constructors? Evaluation of an expression the result of which

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Stanislav Blinov via Digitalmars-d
On Saturday, 22 April 2017 at 16:41:00 UTC, Nordlöw wrote: If defaultValue is not lazy, it's potentially wasteful. What do you mean with "potentially wasteful"? Excess calls to copy constructors? Evaluation of an expression the result of which might not be used. defaultValue could be

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Nordlöw via Digitalmars-d
On Saturday, 22 April 2017 at 15:36:56 UTC, Stanislav Blinov wrote: On Saturday, 22 April 2017 at 12:16:19 UTC, Nordlöw wrote: On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: Is there any way I can make it `@nogc` without having to modify the code in `std.conv`? If I get this to

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Stanislav Blinov via Digitalmars-d
On Saturday, 22 April 2017 at 12:16:19 UTC, Nordlöw wrote: On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: Is there any way I can make it `@nogc` without having to modify the code in `std.conv`? If I get this to work, I'm gonna try pushing it into std.conv. If defaultValue is not

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Nordlöw via Digitalmars-d
On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: if (haveCommonType!(T, U)) Defined as: /// Is `true` iff `Types` all share a common type. enum bool haveCommonType(Types...) = !is(CommonType!Types == void); import std.traits : CommonType;

Re: Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Nordlöw via Digitalmars-d
On Saturday, 22 April 2017 at 12:14:26 UTC, Nordlöw wrote: Is there any way I can make it `@nogc` without having to modify the code in `std.conv`? If I get this to work, I'm gonna try pushing it into std.conv.

Default-valued nothrow @nogc std.conv:to

2017-04-22 Thread Nordlöw via Digitalmars-d
Have anyone tried to implement a variant of `std.conv.to` that can be `nothrow @nogc` if the exception handling is replaced by an extra second parameter (`defaultValue`) returned iff the call to `to` throws? I currently have a solution