On Saturday, 26 April 2014 at 06:24:26 UTC, Ali Çehreli wrote:
On 04/22/2014 11:45 AM, monarch_dodra wrote:
> Reduce returns "the seed". It's actually doing something more
like this:
>
> int[1] foo()
> {
> int[1] sum
> sum = sum[]; //The lambda operates, and the
> //r
On 04/22/2014 11:45 AM, monarch_dodra wrote:
> Reduce returns "the seed". It's actually doing something more like this:
>
> int[1] foo()
> {
> int[1] sum
> sum = sum[]; //The lambda operates, and the
> //result is assigned back to the seed.
> return sum; //Returns
On Tuesday, 22 April 2014 at 18:49:41 UTC, Steven Schveighoffer
wrote:
On Tue, 22 Apr 2014 14:47:19 -0400, monarch_dodra
wrote:
In this case no, but;
//
int[1] foo();
int[] a = foo();
//
*is* slicing an rvalue, and it *does* compile. I don't think
there needs to be escape analysis to
On Tuesday, 22 April 2014 at 18:17:58 UTC, Ali Çehreli wrote:
On 04/22/2014 11:03 AM, monarch_dodra wrote:
> The "int[] reduce...", however, I think is a outright
language issue.
> Implicilty calling opSlice on a static array is one thing,
but doing it
> on an rvalue is an outright aberration. Th
On Tuesday, 22 April 2014 at 18:34:47 UTC, Steven Schveighoffer
wrote:
On Tue, 22 Apr 2014 14:17:57 -0400, Ali Çehreli
wrote:
I don't think there is slicing an rvalue though. (?) reduce()
is taking a copy of the seed and then returning a slice to it
because the user slices it in their lambda
On Tue, 22 Apr 2014 14:47:19 -0400, monarch_dodra
wrote:
In this case no, but;
//
int[1] foo();
int[] a = foo();
//
*is* slicing an rvalue, and it *does* compile. I don't think there needs
to be escape analysis to catch this.
Oh yeah, that's bad.
-Steve
On Tue, 22 Apr 2014 14:17:57 -0400, Ali Çehreli wrote:
I don't think there is slicing an rvalue though. (?) reduce() is taking
a copy of the seed and then returning a slice to it because the user
slices it in their lambda. It effectively does the following, which
unfortunately compiles:
On 04/22/2014 11:03 AM, monarch_dodra wrote:
> On Tuesday, 22 April 2014 at 17:31:22 UTC, Ali Çehreli wrote:
>> I opened the following bug before reading reduce's documentation
>> carefully:
>>
>> https://issues.dlang.org/show_bug.cgi?id=12610
>>
>> import std.stdio;
>> import std.algorithm;
>>
On Tuesday, 22 April 2014 at 17:31:22 UTC, Ali Çehreli wrote:
I opened the following bug before reading reduce's
documentation carefully:
https://issues.dlang.org/show_bug.cgi?id=12610
import std.stdio;
import std.algorithm;
void main()
{
int[] arr = [ 0 ];
int[1] seed;
int[] r
I opened the following bug before reading reduce's documentation carefully:
https://issues.dlang.org/show_bug.cgi?id=12610
import std.stdio;
import std.algorithm;
void main()
{
int[] arr = [ 0 ];
int[1] seed;
int[] result = reduce!((sum, _) => sum[])(seed, arr);
writefln("%s
10 matches
Mail list logo