Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-14 Thread downs
Jeremie Pelletier wrote: Andrei Alexandrescu wrote: Chris Nicholson-Sauls wrote: downs wrote: Here is a funny consequence of this amusing fact: if you overload opAssign in a struct with lazy T[] dgs..., you can achieve the following syntax WithFlag(GL_BLEND, true) =

Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread downs
Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~= dg(); throw new Exception(str); } } void main() { Assert(false, O hai thar! ); }

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Andrei Alexandrescu
downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~= dg(); throw new Exception(str); } } void main() { Assert(false, O hai thar! );

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Don
Andrei Alexandrescu wrote: downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~= dg(); throw new Exception(str); } } void main() {

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Max Samukha
On Tue, 13 Oct 2009 15:06:25 +0200, downs default_357-l...@yahoo.de wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~= dg(); throw new

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Andrei Alexandrescu
Max Samukha wrote: On Tue, 13 Oct 2009 15:06:25 +0200, downs default_357-l...@yahoo.de wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~=

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread downs
downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~= dg(); throw new Exception(str); } } void main() { Assert(false, O

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Leandro Lucarella
Andrei Alexandrescu, el 13 de octubre a las 10:30 me escribiste: downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str ~= dg();

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Jeremie Pelletier
Leandro Lucarella wrote: Andrei Alexandrescu, el 13 de octubre a las 10:30 me escribiste: downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str; foreach (dg; dgs) str

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Chris Nicholson-Sauls
downs wrote: Here is a funny consequence of this amusing fact: if you overload opAssign in a struct with lazy T[] dgs..., you can achieve the following syntax WithFlag(GL_BLEND, true) = WithDepthMask(false) = tex.With = Quads = { foreach (i, q; qa) { float f = 1f*i /

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Andrei Alexandrescu
Chris Nicholson-Sauls wrote: downs wrote: Here is a funny consequence of this amusing fact: if you overload opAssign in a struct with lazy T[] dgs..., you can achieve the following syntax WithFlag(GL_BLEND, true) = WithDepthMask(false) = tex.With = Quads = { foreach (i, q; qa)

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Andrei Alexandrescu
Jeremie Pelletier wrote: Leandro Lucarella wrote: Andrei Alexandrescu, el 13 de octubre a las 10:30 me escribiste: downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug if (!cond) { string str;

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Jeremie Pelletier
Andrei Alexandrescu wrote: Jeremie Pelletier wrote: Leandro Lucarella wrote: Andrei Alexandrescu, el 13 de octubre a las 10:30 me escribiste: downs wrote: Did you know the following code compiles? module test; import std.stdio; void Assert(bool cond, string delegate()[] dgs...) { debug

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Jeremie Pelletier
Chris Nicholson-Sauls wrote: downs wrote: Here is a funny consequence of this amusing fact: if you overload opAssign in a struct with lazy T[] dgs..., you can achieve the following syntax WithFlag(GL_BLEND, true) = WithDepthMask(false) = tex.With = Quads = { foreach (i, q; qa)

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Jeremie Pelletier
Andrei Alexandrescu wrote: Chris Nicholson-Sauls wrote: downs wrote: Here is a funny consequence of this amusing fact: if you overload opAssign in a struct with lazy T[] dgs..., you can achieve the following syntax WithFlag(GL_BLEND, true) = WithDepthMask(false) = tex.With = Quads =

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread Steven Schveighoffer
On Tue, 13 Oct 2009 16:39:13 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: As far as lazy goes, I think the lazy variadic functions are a compelling feature that renders lazy unnecessary. Do you mean lazy in the way that lazy variadic functions *imply* lazy via typing