On 2/8/20 1:20 PM, ag0aep6g wrote:
On 08.02.20 15:57, Steven Schveighoffer wrote:
This kind of stuff is so difficult to reason about and develop as a
library that people will just end up removing dip1000 from their
compilation.
I 100% agree that DIP 1000 is hard to reason about. It's pretty l
On 08.02.20 07:27, ag0aep6g wrote:
On 08.02.20 02:38, ag0aep6g wrote:
Simplified, we're looking at this:
struct Joiner
{
int[3] _items;
int[] _current;
}
void main() @safe
{
Joiner j;
j._current = j._items[];
}
[...]
In the first reduction, `j` might be `scope`, b
On 08.02.20 15:57, Steven Schveighoffer wrote:
This kind of stuff is so difficult to reason about and develop as a
library that people will just end up removing dip1000 from their
compilation.
I 100% agree that DIP 1000 is hard to reason about. It's pretty limited
by design, and the implement
On 2/7/20 8:38 PM, ag0aep6g wrote:
If that code were allowed, you could do this:
struct Joiner
{
Joiner* p;
}
Joiner g;
void main() @safe
{
scope Joiner j;
() @trusted { j.p = &j; } (); /* pretend it's allowed */
g = *j.p; /* dereference and copy */
}
Returning a
On 08.02.20 02:38, ag0aep6g wrote:
Simplified, we're looking at this:
struct Joiner
{
int[3] _items;
int[] _current;
}
void main() @safe
{
Joiner j;
j._current = j._items[];
}
I.e., a self-referential struct. Or most fundamentally:
struct Joiner
{
Joiner
On 08.02.20 01:17, Steven Schveighoffer wrote:
The original code is not invalid though. f is not valid, and that is a
bug, but the original code posted by nullptr should be fine by memory
safety standards.
Maybe. But then it should also work with `int[3] front;`.
If there is no possible way t
On 2/7/20 6:30 PM, ag0aep6g wrote:
On 08.02.20 00:10, nullptr wrote:
```
import std;
struct SomeRange
{
int[3] val;
enum empty = false;
auto popFront() @safe {}
ref auto front() @safe
{
return val;
}
}
void main() @safe
{
SomeRange().take(10).map!
On 2/7/20 6:10 PM, nullptr wrote:
```
import std;
struct SomeRange
{
int[3] val;
enum empty = false;
auto popFront() @safe {}
ref auto front() @safe
{
return val;
}
}
void main() @safe
{
SomeRange().take(10).map!((return ref x) => x[]).joiner.writ
On 08.02.20 00:10, nullptr wrote:
```
import std;
struct SomeRange
{
int[3] val;
enum empty = false;
auto popFront() @safe {}
ref auto front() @safe
{
return val;
}
}
void main() @safe
{
SomeRange().take(10).map!((return ref x) => x[]).joiner.write
On Friday, 7 February 2020 at 22:55:29 UTC, Dennis wrote:
Oops, minimized a bit too much. Corrected test case:
```
import std;
struct S {
@safe:
int[3] front = [10, 20, 30];
bool empty = false;
void popFront() {empty = true;}
}
void main() @safe {
S.init.map!((return ref x)
On Friday, 7 February 2020 at 21:40:36 UTC, Steven Schveighoffer
wrote:
S.popFront is not @safe, and S is not a template. So no
inferrence.
Oops, minimized a bit too much. Corrected test case:
```
import std;
struct S {
@safe:
int[3] front = [10, 20, 30];
bool empty = false;
voi
On 2/7/20 4:17 PM, Dennis wrote:
On Friday, 7 February 2020 at 20:55:14 UTC, nullptr wrote:
Depending on how your range is structured, it might be possible to
just mark front as returning by ref to make this work.
That's a good one. I can't make front() return by ref, but I can make
front a m
On Friday, 7 February 2020 at 20:55:14 UTC, nullptr wrote:
Depending on how your range is structured, it might be possible
to just mark front as returning by ref to make this work.
That's a good one. I can't make front() return by ref, but I can
make front a member variable of the range struct
On Friday, 7 February 2020 at 20:31:47 UTC, Steven Schveighoffer
wrote:
The only solution I can provide is to wrap the static array
into a range (maybe something like this exists in Phobos?):
Thanks. I was hoping something like that existed in Phobos, but I
can't find anything.
On Friday, 7 February 2020 at 20:13:57 UTC, Dennis wrote:
If I have an input range with element type `int[3]`, how do I
easily turn it into a range of `int` so I can map it?
If it were an int[3][] I could simply cast it to an int[]
before mapping, but I don't want to eagerly turn it into an
arr
On 2/7/20 3:13 PM, Dennis wrote:
If I have an input range with element type `int[3]`, how do I easily
turn it into a range of `int` so I can map it?
If it were an int[3][] I could simply cast it to an int[] before
mapping, but I don't want to eagerly turn it into an array.
I thought of doing th
If I have an input range with element type `int[3]`, how do I
easily turn it into a range of `int` so I can map it?
If it were an int[3][] I could simply cast it to an int[] before
mapping, but I don't want to eagerly turn it into an array.
I thought of doing this:
```
range.map!(x => x[]).joine
17 matches
Mail list logo