On Monday, 9 October 2017 at 17:44:12 UTC, jmh530 wrote:
On Monday, 9 October 2017 at 17:19:42 UTC, Petar Kirov
[ZombineDev] wrote:
Another point is that if the container contains many elements
automatically printing all of them would be ugly, unhelpful
and slow, while printing its identity (I think the address of
the RefCountedStore doesn't change on reallocation) may be
more useful.
This relates to your comment in the bugzilla to format with
'%5r'. This would be similar to using something like head or
tail in R and the printing the result. I consider that a
separate issue. It's really easy to handle this in D with UFCS.
In Mir, you could do slice.select(5).writefln!"%s".
Yes, nowadays I am not so certain that we need a dedicated format
for printing only some of the elements, as for most containers it
should be as simple as container[0..5] or container[].take(5).
What I'm certain though, is that I don't want all my containers
with millions of elements to have their elements printed by
default. The std.format code could probably hide them if they're
too many, but at this point it is better to leave the
customization to the user. Printing the container type, address
and length would be most useful default IMO (but in a better
looking way than what we have now for std.container.array).