Comment #0 by bearophile_hugs — 2010-12-26T02:05:18Z
import std.stdio, std.algorithm;
void main() {
const(int[]) arr1 = [1, 2, 3];
auto sequence1 = map!q{ -a }(arr1);
writeln(sequence1);
const sequence2 = map!q{ -a }(arr1);
writeln(sequence2);
immutable(int[]) arr2 = [1, 2, 3];
immutable sequence3 = map!q{ -a }(arr2);
writeln(sequence3);
}
DMD 2.051 prints:
[-1, -2, -3]
const(Map!(result,const(int[])))
immutable(Map!(result,immutable(int[])))
But I'd like it to print the contents of the second and third lazy sequences too, like (note the semicolons, very useful to tell apart arrays from lazy sequences, see bug 3813 for the rationale):
[-1; -2; -3]
[-1; -2; -3]
[-1; -2; -3]
Or maybe something like:
[-1; -2; -3]
const([-1; -2; -3])
immutable([-1; -2; -3])
But note that this is currently a syntax error:
void main() {
auto a = const([1, 2, 3]);
}
Comment #2 by lt.infiltrator — 2015-12-09T10:43:27Z
2.069 prints the types and contents of the sequences:
============
[-1, -2, -3]
const(MapResult!(unaryFun, const(int)[]))([1, 2, 3])
immutable(MapResult!(unaryFun, immutable(int)[]))([1, 2, 3])
============
Is this acceptable?
Comment #3 by bearophile_hugs — 2015-12-09T12:49:18Z
(In reply to Infiltrator from comment #2)
> 2.069 prints the types and contents of the sequences:
> ============
> [-1, -2, -3]
> const(MapResult!(unaryFun, const(int)[]))([1, 2, 3])
> immutable(MapResult!(unaryFun, immutable(int)[]))([1, 2, 3])
> ============
>
> Is this acceptable?
Yes, closed.