www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [OT] ISO C++ 17 changes

reply Andrea Fontana <nospam example.com> writes:
https://isocpp.org/files/papers/p0636r0.html
Apr 03 2017
parent reply Meta <jared771 gmail.com> writes:
On Monday, 3 April 2017 at 08:53:57 UTC, Andrea Fontana wrote:
 https://isocpp.org/files/papers/p0636r0.html
The fold expressions and inference of constructor template args look very nice. C++ is quickly catching up to D in a lot of areas, although usually still with worse syntax. I don't know how fold expressions could be emulated in D.
Apr 03 2017
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 03.04.2017 20:24, Meta wrote:
 On Monday, 3 April 2017 at 08:53:57 UTC, Andrea Fontana wrote:
 https://isocpp.org/files/papers/p0636r0.html
The fold expressions and inference of constructor template args look very nice. C++ is quickly catching up to D in a lot of areas, although usually still with worse syntax. I don't know how fold expressions could be emulated in D.
String mixins.
Apr 03 2017
parent reply Meta <jared771 gmail.com> writes:
On Monday, 3 April 2017 at 21:33:20 UTC, Timon Gehr wrote:
 On 03.04.2017 20:24, Meta wrote:
 On Monday, 3 April 2017 at 08:53:57 UTC, Andrea Fontana wrote:
 https://isocpp.org/files/papers/p0636r0.html
The fold expressions and inference of constructor template args look very nice. C++ is quickly catching up to D in a lot of areas, although usually still with worse syntax. I don't know how fold expressions could be emulated in D.
String mixins.
I try to avoid string mixins if possible as they're incredibly ugly. I did try hacking something together with templates and string mixins, though, but could not get it to work. I stopped here: template fold(string op, Args...) { static if (Args.length == 1) enum fold = Args[0]; else enum fold = mixin("Args[0] " ~ op ~ " fold!(op, Args[1..$])"); //variable _param_2 cannot be read at compile time } auto f(Args...)(Args args) { return fold!("+", args); } void main() { assert(f(1, 2, 3) == 6); } Any suggestions as to how to get something similar working?
Apr 03 2017
next sibling parent reply Dukc <ajieskola gmail.com> writes:
On Monday, 3 April 2017 at 21:43:41 UTC, Meta wrote:
 On Monday, 3 April 2017 at 21:33:20 UTC, Timon Gehr wrote:
 Any suggestions as to how to get something similar working?
auto fold(string op, Args...)(Args args) { foreach(e; args[1 .. $]) args[0] += e; return args[0]; } void main() { import std.stdio; fold!"+"(1, 2, 3).writeln; //6 }
Apr 03 2017
next sibling parent Dukc <ajieskola gmail.com> writes:
^ sorry misquote
Apr 03 2017
prev sibling parent reply Meta <jared771 gmail.com> writes:
On Tuesday, 4 April 2017 at 05:04:04 UTC, Dukc wrote:
 On Monday, 3 April 2017 at 21:43:41 UTC, Meta wrote:
 On Monday, 3 April 2017 at 21:33:20 UTC, Timon Gehr wrote:
 Any suggestions as to how to get something similar working?
auto fold(string op, Args...)(Args args) { foreach(e; args[1 .. $]) args[0] += e; return args[0]; } void main() { import std.stdio; fold!"+"(1, 2, 3).writeln; //6 }
This does work I guess. I'm not sure if the foreach will be unrolled or not but if it is I guess this is fairly close to the C++ example. However, it's still more verbose. My goal was to emulate almost exactly what C++ was doing by using a template so you could just write "fold!('+', args)" and have it automatically rewritten as "Args[0] + Args[1] + Args[2] ...". However it gets difficult because the compiler is trying to interpret args at compile time.
Apr 04 2017
parent reply ag0aep6g <anonymous example.com> writes:
On 04/04/2017 03:29 PM, Meta wrote:
 On Tuesday, 4 April 2017 at 05:04:04 UTC, Dukc wrote:
[...]
     fold!"+"(1, 2, 3).writeln; //6
[...]
 However, it's still more verbose. My goal was to emulate almost exactly
 what C++ was doing by using a template so you could just write
 "fold!('+', args)"
I'm probably missing something, but `fold!"+"(args)` isn't more verbose than `fold!('+', args)`.
Apr 04 2017
parent reply Meta <jared771 gmail.com> writes:
On Tuesday, 4 April 2017 at 13:38:57 UTC, ag0aep6g wrote:
 On 04/04/2017 03:29 PM, Meta wrote:
 On Tuesday, 4 April 2017 at 05:04:04 UTC, Dukc wrote:
[...]
     fold!"+"(1, 2, 3).writeln; //6
[...]
 However, it's still more verbose. My goal was to emulate 
 almost exactly
 what C++ was doing by using a template so you could just write
 "fold!('+', args)"
I'm probably missing something, but `fold!"+"(args)` isn't more verbose than `fold!('+', args)`.
I mean what goes on inside fold. If you look at the C++ example it's very concise and IMO beautiful: <typename ...Args> auto f(Args ...args) { return (0 + ... + args); } So I wanted a solution that was about the same in terms of brevity. My first attempt was: enum fold(string op, Args...) = mixin("Args[0] " ~ op ~ " fold!(op, Args[1..$])"; But of course this doesn't work.
Apr 04 2017
next sibling parent Dukc <ajieskola gmail.com> writes:
On Tuesday, 4 April 2017 at 13:45:47 UTC, Meta wrote:
 I mean what goes on inside fold. If you look at the C++ example 
 it's very concise and IMO beautiful:
Luckily that hardly matters, you just need to define one generic template for the whole program, which can even be in a library. Btw my fold template implementation was erroneous, I forgot to mixin the operator string passed to it.
Apr 04 2017
prev sibling next sibling parent ag0aep6g <anonymous example.com> writes:
On 04/04/2017 03:45 PM, Meta wrote:
 I mean what goes on inside fold.
Ok. That's what I missed.
 If you look at the C++ example it's
 very concise and IMO beautiful:

 <typename ...Args> auto f(Args ...args) { return (0 + ... + args); }
But the shown `fold` implements the functionality of that C++ language feature. That is, you have to compare `fold!"+"(args)` with `(0 + ... + args)`. The C++ version may be more beautiful, but verbosity seems about the same. I think I accidentally sent this directly to your email, too. Sorry about that; Thunderbird's "answer" buttons can be confusing for me.
Apr 04 2017
prev sibling parent Martin Nowak <code dawg.eu> writes:
On Tuesday, 4 April 2017 at 13:45:47 UTC, Meta wrote:
 I mean what goes on inside fold. If you look at the C++ example 
 it's very concise and IMO beautiful:

 <typename ...Args> auto f(Args ...args) { return (0 + ... + 
 args); }
It's special syntax for a very limited (only infix operators) and rather obscure use-case. There are many different ways to do this already, recursive calls, static foreach, string mixin, and they work with any reduce function/op. It seems the reason C++ needs this, is because parameter pack expansion is so restricted (and complex at the same time http://en.cppreference.com/w/cpp/language/parameter_pack). Compare this with a fully generic fold in a few lines. fold(alias op, Args...)(Args args) if (Args.length > 1) { static if (Args.length > 2) return op(args[0], fold!op(args[1 .. $])); else return op(args[0], args[1]); }
Apr 08 2017
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 03.04.2017 23:43, Meta wrote:
 On Monday, 3 April 2017 at 21:33:20 UTC, Timon Gehr wrote:
 On 03.04.2017 20:24, Meta wrote:
 On Monday, 3 April 2017 at 08:53:57 UTC, Andrea Fontana wrote:
 https://isocpp.org/files/papers/p0636r0.html
The fold expressions and inference of constructor template args look very nice. C++ is quickly catching up to D in a lot of areas, although usually still with worse syntax. I don't know how fold expressions could be emulated in D.
String mixins.
I try to avoid string mixins if possible as they're incredibly ugly. I did try hacking something together with templates and string mixins, though, but could not get it to work. I stopped here: template fold(string op, Args...) { static if (Args.length == 1) enum fold = Args[0]; else enum fold = mixin("Args[0] " ~ op ~ " fold!(op, Args[1..$])"); //variable _param_2 cannot be read at compile time } auto f(Args...)(Args args) { return fold!("+", args); } void main() { assert(f(1, 2, 3) == 6); } Any suggestions as to how to get something similar working?
I usually just use: mixin(iota(args.length).map!(i=>text("args[",i,"]")).join("+")) Obvious and fully customizable; IMHO, the aesthetics are actually better than for the C++ example: "0 + ... + args" ? "0 + args" does not make sense, so why should "0 + ... + args" ? Furthermore, the feature explicitly special-cases operators (why not allow fold over arbitrary binary functions?) and adds a few more rules to C++'s language definition.
Apr 06 2017
prev sibling next sibling parent reply mogu <mogucpp 163.com> writes:
On Monday, 3 April 2017 at 18:24:31 UTC, Meta wrote:
 On Monday, 3 April 2017 at 08:53:57 UTC, Andrea Fontana wrote:
 https://isocpp.org/files/papers/p0636r0.html
The fold expressions and inference of constructor template args look very nice. C++ is quickly catching up to D in a lot of areas, although usually still with worse syntax. I don't know how fold expressions could be emulated in D.
Structured bindings and class template arguments deduction are parts D realy loose. Wish D can implement quickly. Cpp20 may bring more attributes like concept, asio, coroutines and so on. Come on! D! Beats them all.
Apr 03 2017
parent reply evilrat <evilrat666 gmail.com> writes:
On Tuesday, 4 April 2017 at 00:46:25 UTC, mogu wrote:
 On Monday, 3 April 2017 at 18:24:31 UTC, Meta wrote:
 On Monday, 3 April 2017 at 08:53:57 UTC, Andrea Fontana wrote:
 https://isocpp.org/files/papers/p0636r0.html
The fold expressions and inference of constructor template args look very nice. C++ is quickly catching up to D in a lot of areas, although usually still with worse syntax. I don't know how fold expressions could be emulated in D.
Structured bindings and class template arguments deduction are parts D realy loose. Wish D can implement quickly. Cpp20 may bring more attributes like concept, asio, coroutines and so on. Come on! D! Beats them all.
String interpolation would be nice too, it would really help with readability!
Apr 03 2017
next sibling parent reply Dukc <ajieskola gmail.com> writes:
On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 String interpolation would be nice too, it would really help 
 with readability!
If you mean runtime interpolation, that means one has to bundle the interpreter with the executable, and sacrifice alot of code speed. I recall that there is a DUB package which lets you use DMD as interpreter but it is Linux-only. Also Arsd-official library does contain an interpreter of some sort of script language that looks much like D, but is not quite. Stupid D compiler, if it some day compiles the standard library, I believe it will become a good interpreter. But if all you want is to construct some code in interpreter-like way at compile time, string mixin does precisely that.
Apr 03 2017
parent reply evilrat <evilrat666 gmail.com> writes:
On Tuesday, 4 April 2017 at 05:18:26 UTC, Dukc wrote:
 On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 String interpolation would be nice too, it would really help 
 with readability!
But if all you want is to construct some code in interpreter-like way at compile time, string mixin does precisely that.
No, just static symbols will be enough. Not really interpreter but common day-to-day things like print some formatted stuff while keep it readable. I know it is easy to do with string.format() but it'll add more commas, templates, mixins or all at once, which is without decent tools like Visual Assist for C++ doesn't really makes it better. void printStuff() { int someInt = calcSmth(); string someName = getSmthDisplayName(); // ... do other things ... writeln("Your item: {#someName} = {#someInt}"); }
Apr 03 2017
parent reply Patrick Schluter <Patrick.Schluter bbox.fr> writes:
On Tuesday, 4 April 2017 at 05:36:55 UTC, evilrat wrote:
 On Tuesday, 4 April 2017 at 05:18:26 UTC, Dukc wrote:
 On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 [...]
But if all you want is to construct some code in interpreter-like way at compile time, string mixin does precisely that.
No, just static symbols will be enough. Not really interpreter but common day-to-day things like print some formatted stuff while keep it readable. I know it is easy to do with string.format() but it'll add more commas, templates, mixins or all at once, which is without decent tools like Visual Assist for C++ doesn't really makes it better. void printStuff() { int someInt = calcSmth(); string someName = getSmthDisplayName(); // ... do other things ... writeln("Your item: {#someName} = {#someInt}"); }
writeln("Your item: ", someName, " = ", someInt"); ????
Apr 03 2017
parent reply evilrat <evilrat666 gmail.com> writes:
On Tuesday, 4 April 2017 at 05:53:00 UTC, Patrick Schluter wrote:
 On Tuesday, 4 April 2017 at 05:36:55 UTC, evilrat wrote:
 On Tuesday, 4 April 2017 at 05:18:26 UTC, Dukc wrote:
 On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 [...]
writeln("Your item: ", someName, " = ", someInt"); ????
This works due to variadic args nature of writeln, but the point is that it might be used with simple string assignment and other functions that takes one string, besides, the point is to avoid clutter and improve readability of code.
Apr 03 2017
parent reply Andrea Fontana <nospam example.com> writes:
On Tuesday, 4 April 2017 at 06:13:24 UTC, evilrat wrote:
 On Tuesday, 4 April 2017 at 05:53:00 UTC, Patrick Schluter 
 wrote:
 On Tuesday, 4 April 2017 at 05:36:55 UTC, evilrat wrote:
 On Tuesday, 4 April 2017 at 05:18:26 UTC, Dukc wrote:
 On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 [...]
writeln("Your item: ", someName, " = ", someInt"); ????
This works due to variadic args nature of writeln, but the point is that it might be used with simple string assignment and other functions that takes one string, besides, the point is to avoid clutter and improve readability of code.
text("Your item: ", someName, " = ", someInt");
Apr 04 2017
parent reply evilrat <evilrat666 gmail.com> writes:
On Tuesday, 4 April 2017 at 07:21:09 UTC, Andrea Fontana wrote:
 On Tuesday, 4 April 2017 at 06:13:24 UTC, evilrat wrote:
 On Tuesday, 4 April 2017 at 05:53:00 UTC, Patrick Schluter 
 wrote:
 On Tuesday, 4 April 2017 at 05:36:55 UTC, evilrat wrote:
 On Tuesday, 4 April 2017 at 05:18:26 UTC, Dukc wrote:
 On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 [...]
writeln("Your item: ", someName, " = ", someInt"); ????
This works due to variadic args nature of writeln, but the point is that it might be used with simple string assignment and other functions that takes one string, besides, the point is to avoid clutter and improve readability of code.
text("Your item: ", someName, " = ", someInt");
Well, thanks, I guess... But it seems no one else interested in such feature. I get it. Sure this shouldn't be top priority thing and it can(it surely will) be hard to implement in compiler, and this maybe not an option for such a little benefit, but at least I can dream one day it will made it in D, yay.
Apr 04 2017
parent reply Guillaume Piolat <first.last gmail.com> writes:
On Tuesday, 4 April 2017 at 08:16:48 UTC, evilrat wrote:
 Well, thanks, I guess... But it seems no one else interested in 
 such feature. I get it.
 Sure this shouldn't be top priority thing and it can(it surely 
 will) be hard to implement in compiler, and this maybe not an 
 option for such a little benefit, but at least I can dream one 
 day it will made it in D, yay.
There is a library solution in scriptlike: https://p0nce.github.io/d-idioms/#String-interpolation-as-a-library I think you only ever miss it when doing web stuff.
Apr 04 2017
parent evilrat <evilrat666 gmail.com> writes:
On Tuesday, 4 April 2017 at 10:40:19 UTC, Guillaume Piolat wrote:
 On Tuesday, 4 April 2017 at 08:16:48 UTC, evilrat wrote:
 Well, thanks, I guess... But it seems no one else interested 
 in such feature. I get it.
 Sure this shouldn't be top priority thing and it can(it surely 
 will) be hard to implement in compiler, and this maybe not an 
 option for such a little benefit, but at least I can dream one 
 day it will made it in D, yay.
There is a library solution in scriptlike: https://p0nce.github.io/d-idioms/#String-interpolation-as-a-library I think you only ever miss it when doing web stuff.
Сool, i was thinking about the same, just make interp with alias and mixin... But this lib has some other interesting functions too! Though not in Phobos, but at least dub makes it super quick to use. Thanks! No, not web stuff, just quick dirty concepting stuff. Unfortunatelly this days I usually deal with C++ only :/
Apr 04 2017
prev sibling parent reply Xinok <xinok live.com> writes:
On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 String interpolation would be nice too, it would really help 
 with readability!
This really isn't in the spirit of D and is better left to library functions which give the user far more power and flexibility. Incorporating such a feature into the language raises many questions and concerns: * It becomes a language feature thereby further bloating the language and runtime * What if you want it to be nogc? * What if you want to combine it with allocators? * What if you want to store the result in a particular buffer? * What if you want the result to be lazily evaluated? * What if you want an input range of chars? ... that is lazily evaluated? * What if you want to format the arguments in a specific way? Given the ease in which such a feature can be implemented and used as a library function, I don't see interpolated strings as being a necessary feature in D.
Apr 04 2017
parent reply Russel Winder via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Tue, 2017-04-04 at 12:46 +0000, Xinok via Digitalmars-d wrote:
 On Tuesday, 4 April 2017 at 02:43:26 UTC, evilrat wrote:
 String interpolation would be nice too, it would really help=C2=A0
 with readability!
=20 This really isn't in the spirit of D and is better left to=C2=A0 library functions which give the user far more power and=C2=A0 flexibility. Incorporating such a feature into the language=C2=A0 raises many questions and concerns:
Interestingly, or not, Python 3.6 introduces string interpolation even though Python already has the format function. And pythonistas are happy about this.
 * It becomes a language feature thereby further bloating the=C2=A0
 language and runtime
 * What if you want it to be  nogc?
 * What if you want to combine it with allocators?
 * What if you want to store the result in a particular buffer?
 * What if you want the result to be lazily evaluated?
 * What if you want an input range of chars? ... that is lazily=C2=A0
 evaluated?
 * What if you want to format the arguments in a specific way?
=20
 Given the ease in which such a feature can be implemented and=C2=A0
 used as a library function, I don't see interpolated strings as=C2=A0
 being a necessary feature in D.
--=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 04 2017
parent reply Jack Stouffer <jack jackstouffer.com> writes:
On Tuesday, 4 April 2017 at 15:41:08 UTC, Russel Winder wrote:
 Interestingly, or not, Python 3.6 introduces string 
 interpolation even though Python already has the format 
 function. And pythonistas are happy about this.
I can say the redditor Python userbase wasn't. The same sentiment was repeated by every comment: "So now there's three ways to format a string that all do the same thing? Why?".
Apr 06 2017
parent reply Russel Winder via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Thu, 2017-04-06 at 21:02 +0000, Jack Stouffer via Digitalmars-d
wrote:
 On Tuesday, 4 April 2017 at 15:41:08 UTC, Russel Winder wrote:
 Interestingly, or not, Python 3.6 introduces string=C2=A0
 interpolation even though Python already has the format=C2=A0
 function. And pythonistas are happy about this.
=20 I can say the redditor Python userbase wasn't. The same sentiment=C2=A0 was repeated by every comment: "So now there's three ways to=C2=A0 format a string that all do the same thing? Why?".
Different communities then. I don't do Reddit =E2=80=93 waste of time. Why three? There is the format function and now f-strings, that makes two. =20 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 07 2017
parent reply Jack Stouffer <jack jackstouffer.com> writes:
On Friday, 7 April 2017 at 09:01:37 UTC, Russel Winder wrote:
 Why three? There is the format function and now f-strings, that 
 makes two.
1. the format function 2. the new format strings 3. the old "" % syntax
Apr 07 2017
parent Russel Winder via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Fri, 2017-04-07 at 14:05 +0000, Jack Stouffer via Digitalmars-d
wrote:
 On Friday, 7 April 2017 at 09:01:37 UTC, Russel Winder wrote:
 Why three? There is the format function and now f-strings, that=C2=A0
 makes two.
=20 1. the format function 2. the new format strings 3. the old "" % syntax
Well 3 doesn't count, it is deprecated. ;-) --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 07 2017
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/3/2017 11:24 AM, Meta wrote:
 I don't know how fold expressions could be emulated in D.
Apr 04 2017
next sibling parent reply Meta <jared771 gmail.com> writes:
On Tuesday, 4 April 2017 at 08:38:32 UTC, Walter Bright wrote:
 On 4/3/2017 11:24 AM, Meta wrote:
 I don't know how fold expressions could be emulated in D.
Not quite the same as this is a fold over a TypeTuple/AliasSeq. You could of course do: only(args).fold!"a + b"() But the semantics are different.
Apr 04 2017
parent Nick Treleaven <nick geany.org> writes:
On Tuesday, 4 April 2017 at 13:30:47 UTC, Meta wrote:
 On Tuesday, 4 April 2017 at 08:38:32 UTC, Walter Bright wrote:

Not quite the same as this is a fold over a TypeTuple/AliasSeq. You could of course do: only(args).fold!"a + b"() But the semantics are different.
To avoid the runtime loop above, we could add an overload fold(alias fun, A...)(A args). (There are already min, max that take variadic arguments in std.algorithm). I think this would be more powerful than the C++ feature as it would support any function. To make it a little nicer, we could have binaryFun accept operators as strings, e.g. fold!"+"(args). Doing that would allow e.g. sort!">"(r).
Apr 05 2017
prev sibling parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
On Tue, Apr 04, 2017 at 01:38:32AM -0700, Walter Bright via Digitalmars-d wrote:
 On 4/3/2017 11:24 AM, Meta wrote:
 I don't know how fold expressions could be emulated in D.
That is not what "fold expressions" mean. Fold expressions are newly-introduced C++ syntax where you can write: bool b = ... && args; (with a literal "...") and the compiler automatically expands it to `args[0] && args[1] && args[2]` (assuming args has 3 elements). Of course, whether or not D ought to have such a thing is up for debate. My present opinion is that D doesn't need it, because D's compile-time capabilities are already convenient enough to use without needing special syntax support from the language. T -- Customer support: the art of getting your clients to pay for your own incompetence.
Apr 04 2017