On Sunday, 29 May 2016 at 18:02:53 UTC, Steven Schveighoffer
wrote:
You can create a trusted expression by using a lambda and
immediately calling it. ag0aep6g brought it up.
I would write it like this (untested, but I think this works):
return (()@trusted => )().doSomething();
The key is to
On 5/28/16 7:50 AM, Lodovico Giaretta wrote:
Let's say I have a generic function that uses pointers. It will be
inferred @system by the compiler, but I know that the pointer usage can
be @trusted.
The problem is that if I declare the function @trusted, I'm also
implicitly trusting any call to
On Saturday, 28 May 2016 at 14:54:13 UTC, Era Scarecrow wrote:
Well here's what i got. Maybe someone else will tell me how i
did this wrong...
Using the pragma to output how the lines were being generated i
finally figured out why it kept complaining about the stack
pointer and 'this'. So
On Saturday, 28 May 2016 at 14:11:56 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote:
Do you still want the template i'm building?
Thank you very much for your effort.
Please if you don't need it, don't make it, because I don't
know if I'll use
On 05/28/2016 02:43 PM, Lodovico Giaretta wrote:
struct S1
{
int doSomething() @safe
{
// do something safely
return 1;
}
}
struct S2
{
int doSomething() @system
{
// do something usafe
return 2;
}
}
auto doSomethingDumb(T)(ref
On Saturday, 28 May 2016 at 14:11:56 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote:
Do you still want the template i'm building?
Thank you very much for your effort.
Please if you don't need it, don't make it, because I don't
know if I'll use
On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote:
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta
wrote:
The only problem is that these structures are parameterized,
and the type parameters may have unsafe operations that I use.
Do you still want the template i'm
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta wrote:
The only problem is that these structures are parameterized,
and the type parameters may have unsafe operations that I use.
Do you still want the template i'm building? It doesn't like
stack frame pointers, but will work with
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 13:03:10 UTC, Adam D. Ruppe wrote:
What kind of pointer usage do you have? Remember that basic &
and * operations ARE @safe.
If you have more internally, you might be able to wrap them up
in an
On Saturday, 28 May 2016 at 13:03:10 UTC, Adam D. Ruppe wrote:
What kind of pointer usage do you have? Remember that basic &
and * operations ARE @safe.
If you have more internally, you might be able to wrap them up
in an @trusted function to again allow inference to work.
Ouch! I was under
On Saturday, 28 May 2016 at 11:50:33 UTC, Lodovico Giaretta wrote:
Let's say I have a generic function that uses pointers. It will
be inferred @system by the compiler, but I know that the
pointer usage can be @trusted.
What kind of pointer usage do you have? Remember that basic & and
*
On Saturday, 28 May 2016 at 12:45:21 UTC, Era Scarecrow wrote:
Fourth, you could create a helper function/template that
cycles through a struct of your choice and tells you if any of
it's methods fail to be safe. This will require a little more
work, but it could be used as a full insurance
On Saturday, 28 May 2016 at 12:45:21 UTC, Era Scarecrow wrote:
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta
wrote:
The problem is that T is a type, and I should check for safety
of every method of T that I'm using in my function. This does
not scale well, and if I change the
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta wrote:
The problem is that T is a type, and I should check for safety
of every method of T that I'm using in my function. This does
not scale well, and if I change the body of the function to use
a new method, I may forget to add it
On Saturday, 28 May 2016 at 12:33:28 UTC, Era Scarecrow wrote:
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta
wrote:
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
The problem is that T is a type, and I should
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
The problem is that T is a type, and I should check for safety
of every method of T that I'm using in my
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
Use traits..
https://dlang.org/phobos/std_traits.html#isSafe
so your function becomes (i believe)
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
The problem is that T is a type, and I should check for safety of
every
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
Should also probably test for a function or delegate. So...?
auto doSomethingDumb(T)(ref T t)
if(isSafe!T && (isFunctionPointer!T || isDelegate!T)) {
T* pt =
On Saturday, 28 May 2016 at 11:50:33 UTC, Lodovico Giaretta wrote:
Is there any way around this? Any way to declare a function
@trusted as long as the methods of the template argument are at
least @trusted?
Thank you in advance.
Use traits..
https://dlang.org/phobos/std_traits.html#isSafe
Let's say I have a generic function that uses pointers. It will
be inferred @system by the compiler, but I know that the pointer
usage can be @trusted.
The problem is that if I declare the function @trusted, I'm also
implicitly trusting any call to @system methods of the template
parameter.
20 matches
Mail list logo