On Monday, 7 May 2018 at 10:20:22 UTC, ag0aep6g wrote:
On 05/07/2018 04:41 AM, wjoe wrote:
Could you elaborate on the unsafe destructor please?
If TFunc has an unsafe destructor, asDelegate is also not safe
and can't be @trusted.
An example of how that can break safety:
auto asDelegat
On 05/07/2018 04:41 AM, wjoe wrote:
Could you elaborate on the unsafe destructor please?
If TFunc has an unsafe destructor, asDelegate is also not safe and can't
be @trusted.
An example of how that can break safety:
auto asDelegate(TFunc)(TFunc func) @trusted
{
import std.function
Thanks for replying.
On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
On 05/04/2018 06:33 PM, Neia Neutuladh wrote:
auto asDelegate(TFunc)(TFunc func) @trusted
{
import std.functional : toDelegate;
return toDelegate(func);
}
The "@trusted" means that you promise this thing is s
Thanks for replying.
On Saturday, 5 May 2018 at 00:30:35 UTC, Neia Neutuladh wrote:
On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
[...] If it's a user-defined type with opCall, that's something
to pay attention to, but it's beyond the scope of the original
question.
Actually it's no
On 05/05/2018 02:30 AM, Neia Neutuladh wrote:
On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
If toDelegate isn't (always) @safe, how can you be sure that your
wrapper is?
[...]
Looking at the code, I believe there are several casts that the compiler
can't verify but are used safely.
On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
If toDelegate isn't (always) @safe, how can you be sure that
your wrapper is?
If it were @safe, the compiler would accept it.
Looking at the code, I believe there are several casts that the
compiler can't verify but are used safely.
Al
On 05/04/2018 06:33 PM, Neia Neutuladh wrote:
auto asDelegate(TFunc)(TFunc func) @trusted
{
import std.functional : toDelegate;
return toDelegate(func);
}
The "@trusted" means that you promise this thing is safe, even if the
compiler can't be certain.
If toDelegate isn't (always) @s
On Friday, 4 May 2018 at 15:36:29 UTC, wjoe wrote:
I have a class that I want to be able to register callbacks and
I'd like to be able to register any callable - functions,
delegates, lambdas, anything.
Is there another way to do it besides converting those
toDelegate, which states a bug with
I have a class that I want to be able to register callbacks and
I'd like to be able to register any callable - functions,
delegates, lambdas, anything.
Is there another way to do it besides converting those
toDelegate, which states a bug with @safe functions?
Or better store each type in the