April 07, 2017
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
April 07, 2017
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 makes two.
> 
> 1. the format function
> 2. the new format strings
> 3. the old "" % syntax

Well 3 doesn't count, it is deprecated. ;-)

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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

April 08, 2017
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]);
  }
1 2 3 4
Next ›   Last »