On Wednesday, 22 August 2018 at 14:05:10 UTC, Steven
Schveighoffer wrote:
But that's not valid dip1000 code. If you call it, it should
give a compiler error (r *does* escape its scope).
When I complained about C++ safety to my C++ programmer
colleague, he told me that the compiler just
On 8/22/18 4:17 AM, Kagamin wrote:
On Tuesday, 21 August 2018 at 14:04:15 UTC, Steven Schveighoffer wrote:
I would guess it's no different than other inferred attributes. I
would also guess that it only gets promoted to a return parameter if
it's actually returned.
If we can't have properly
On Tuesday, 21 August 2018 at 14:04:15 UTC, Steven Schveighoffer
wrote:
I would guess it's no different than other inferred attributes.
I would also guess that it only gets promoted to a return
parameter if it's actually returned.
If we can't have properly typed parameters, it feels like it
On Tuesday, 21 August 2018 at 13:42:31 UTC, Kagamin wrote:
int[] escape(scope int[] r)
{
return r; //error, can't return scoped argument
}
...
int[] escape(T)(scope int[] r)
{
return r; //ok! `scope` silently promoted to `return`
}
You can't have strictly scoped parameter in a
On Tuesday, 21 August 2018 at 11:28:39 UTC, Nicholas Wilson wrote:
On Tuesday, 21 August 2018 at 10:57:15 UTC, Atila Neves wrote:
On Tuesday, 21 August 2018 at 09:50:46 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 15:55:54 UTC, Kagamin wrote:
On Monday, 20 August 2018 at 13:02:23 UTC,
On 8/21/18 9:42 AM, Kagamin wrote:
except for templated functions:
int[] escape(scope int[] r)
{
return r; //error, can't return scoped argument
}
int[] escape(return int[] r)
{
return r; //ok, just as planned
}
int[] escape(return scope int[] r)
{
return r; //ok, `return
...except for templated functions:
int[] escape(scope int[] r)
{
return r; //error, can't return scoped argument
}
int[] escape(return int[] r)
{
return r; //ok, just as planned
}
int[] escape(return scope int[] r)
{
return r; //ok, `return scope` reduced to just `return`
}
int[]
I mean if one method in structure is trusted, other methods need
manual verification too.
On Tuesday, 21 August 2018 at 10:57:15 UTC, Atila Neves wrote:
Also, if I have to remember to annotate correctly, surely this
is a massive hole in @safe dip1000?
In general, safety works per method and doesn't help much in
building safe data structures, those are trusted as a whole. EMSI
On Tuesday, 21 August 2018 at 10:57:15 UTC, Atila Neves wrote:
Never mind, I forgot to use -dip1000. Ok, cool, so _why_ does
it work as intended now? Also, if I have to remember to
annotate correctly, surely this is a massive hole in @safe
dip1000?
It thought dip1000 was impenetrable, but if
On Tuesday, 21 August 2018 at 10:57:15 UTC, Atila Neves wrote:
On Tuesday, 21 August 2018 at 09:50:46 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 15:55:54 UTC, Kagamin wrote:
On Monday, 20 August 2018 at 13:02:23 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 12:56:42 UTC,
On Tuesday, 21 August 2018 at 09:50:46 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 15:55:54 UTC, Kagamin wrote:
On Monday, 20 August 2018 at 13:02:23 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 12:56:42 UTC, Kagamin wrote:
[...]
I need `return` for what exactly? Your code
On Monday, 20 August 2018 at 15:55:54 UTC, Kagamin wrote:
On Monday, 20 August 2018 at 13:02:23 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 12:56:42 UTC, Kagamin wrote:
[...]
I need `return` for what exactly? Your code still compiles,
and my point is it shouldn't. It sure isn't
On Monday, 20 August 2018 at 15:55:54 UTC, Kagamin wrote:
On Monday, 20 August 2018 at 13:02:23 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 12:56:42 UTC, Kagamin wrote:
You need `return` attribute there, not `scope`:
struct MyStruct
{
import core.stdc.stdlib;
int* ints;
On Monday, 20 August 2018 at 13:02:23 UTC, Atila Neves wrote:
On Monday, 20 August 2018 at 12:56:42 UTC, Kagamin wrote:
You need `return` attribute there, not `scope`:
struct MyStruct
{
import core.stdc.stdlib;
int* ints;
this(int size) @trusted { ints = cast(int*) malloc(size); }
On 8/20/18 5:43 AM, Nicholas Wilson wrote:
On Monday, 20 August 2018 at 09:31:09 UTC, Atila Neves wrote:
On Friday, 17 August 2018 at 13:39:29 UTC, Steven Schveighoffer wrote:
// used to be scope int* ptr() { return ints; }
scope inout(int)* ptr() inout { return ints; }
Does scope apply to
On Monday, August 20, 2018 3:43:46 AM MDT Nicholas Wilson via Digitalmars-d
wrote:
> On Monday, 20 August 2018 at 09:31:09 UTC, Atila Neves wrote:
> > On Friday, 17 August 2018 at 13:39:29 UTC, Steven Schveighoffer
> >
> > wrote:
> >>> // used to be scope int* ptr() { return ints; }
> >>> scope
AIU, `return` for `scope` is what `inout` is for `const`. I
proposed to extend `inout` to mean `return`, but Walter said that
they are independent.
On Monday, 20 August 2018 at 09:43:46 UTC, Nicholas Wilson wrote:
On Monday, 20 August 2018 at 09:31:09 UTC, Atila Neves wrote:
On Friday, 17 August 2018 at 13:39:29 UTC, Steven
Schveighoffer wrote:
[...]
Does scope apply to the return value or the `this` reference?
I assumed the return
On Monday, 20 August 2018 at 12:56:42 UTC, Kagamin wrote:
You need `return` attribute there, not `scope`:
struct MyStruct
{
import core.stdc.stdlib;
int* ints;
this(int size) @trusted { ints = cast(int*) malloc(size); }
~this() @trusted { free(ints); }
inout(int)* ptr()
You need `return` attribute there, not `scope`:
struct MyStruct
{
import core.stdc.stdlib;
int* ints;
this(int size) @trusted { ints = cast(int*) malloc(size); }
~this() @trusted { free(ints); }
inout(int)* ptr() return inout { return ints; }
}
On Monday, 20 August 2018 at 09:31:09 UTC, Atila Neves wrote:
On Friday, 17 August 2018 at 13:39:29 UTC, Steven Schveighoffer
wrote:
// used to be scope int* ptr() { return ints; }
scope inout(int)* ptr() inout { return ints; }
Does scope apply to the return value or the `this` reference?
I
On Friday, 17 August 2018 at 13:39:29 UTC, Steven Schveighoffer
wrote:
On 8/17/18 3:36 AM, Atila Neves wrote:
Here's a struct:
-
struct MyStruct {
import core.stdc.stdlib;
int* ints;
this(int size) @trusted { ints = cast(int*) malloc(size);
}
~this()
On Friday, 17 August 2018 at 13:39:29 UTC, Steven Schveighoffer
wrote:
On 8/17/18 3:36 AM, Atila Neves wrote:
Here's a struct:
-
// used to be scope int* ptr() { return ints; }
scope inout(int)* ptr() inout { return ints; }
Does scope apply to the return value or the `this`
On 8/17/18 3:36 AM, Atila Neves wrote:
Here's a struct:
-
struct MyStruct {
import core.stdc.stdlib;
int* ints;
this(int size) @trusted { ints = cast(int*) malloc(size); }
~this() @trusted { free(ints); }
scope int* ptr() { return ints; }
}
25 matches
Mail list logo