Re: Is there something like a consuming take?

2019-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 7, 2019 12:36:42 PM MDT berni via Digitalmars-d-learn wrote: > On Sunday, 7 July 2019 at 09:01:53 UTC, Jonathan M Davis wrote: > > Without slicing, that's impossible without iterating over the > > elements multiple times. > > That's what I thought too, but meanwhile I think it is

Re: Using output-range overloads of SysTime.toISO{Ext}String with formatting code

2019-07-07 Thread drug via Digitalmars-d-learn
07.07.2019 17:49, Joseph Rushton Wakeling пишет: it's possible to do something like `writefln!"%s"(now.toISOExtString)` and have it automatically use the output range overload rather than allocating a new string instance. This is exactly how it is intended to work:

Re: Why are immutable array literals heap allocated?

2019-07-07 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 6 July 2019 at 09:56:57 UTC, ag0aep6g wrote: On 06.07.19 01:12, Patrick Schluter wrote: On Friday, 5 July 2019 at 23:08:04 UTC, Patrick Schluter wrote: On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc {     return [1,2]; } [...] and it

Re: Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator Further notes by Dan (aka "Wild"): I added some small printfs to the compiler, http://ix.io/1NWM It seems like it lowers it into something weird

Re: Is there something like a consuming take?

2019-07-07 Thread berni via Digitalmars-d-learn
On Sunday, 7 July 2019 at 09:01:53 UTC, Jonathan M Davis wrote: Without slicing, that's impossible without iterating over the elements multiple times. That's what I thought too, but meanwhile I think it is possible. To get it working, the second range needs to know about the first one and

Re: Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread a11e99z via Digitalmars-d-learn
On Sunday, 7 July 2019 at 17:07:59 UTC, a11e99z wrote: On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? probably same oops! this one

Re: Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread a11e99z via Digitalmars-d-learn
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? probably same https://forum.dlang.org/post/qd9ee0$2eud$1...@digitalmars.com

Why does `static foreach` lead to something calling `~=` internally?

2019-07-07 Thread 0xEAB via Digitalmars-d-learn
Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? static foreach(i; 0 .. cnt) onlineapp.d(9): Error: cannot use operator ~= in @nogc delegate onlineapp.xv!(myUDA("/")).__funcliteral2.__lambda1 import std.traits; private @safe pure nothrow @nogc

Using output-range overloads of SysTime.toISO{Ext}String with formatting code

2019-07-07 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
Hello folks, Is there an idiomatic/intended way to use the output-range taking overloads of SysTime.toISOString and toISOExtString with stuff like `writeln` and `format`, as opposed to explicitly generating an output range to stdout or a string, and passing that to these methods? I'm a bit

Re: Is there something like a consuming take?

2019-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 6, 2019 12:58:52 PM MDT Adam D. Ruppe via Digitalmars-d- learn wrote: > On Saturday, 6 July 2019 at 18:17:26 UTC, Jonathan M Davis wrote: > > take _always_ consumes the range that it's given > > not if it hasSlicing. see >

Re: Is there something like a consuming take?

2019-07-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 6, 2019 11:02:15 PM MDT berni via Digitalmars-d-learn wrote: > Or better: I'd like to hand in my voucher and get back two > vouchers, one for the first 5 bytes and one for the rest. That's > actually, what I thought, take() is doing... Without slicing, that's impossible without