News for hackers. Stuff that matters.
Re:Mandelbrot set in C++11 by buster on Thursday February 28, 2013 @09:33AM (#5298777)
It's a shame, actually i like C++11 and the new features but seeing the lambda is instantly pushing me away again:

auto func = [] (std::complex <double> z, std::complex<double> c) -> std::complex<double> {return z * z + c; };

Why isn't there some nicer and more readable syntax for some of that basic stuff?!

Re:Mandelbrot set in C++11 by sbmassey on Thursday February 28, 2013 @10:02AM (#5298905)
You can leave out the explicit return type.

  auto func = [] (std::complex<double> z, std::complex<double> c) { return z * z + c; };
You could also typedef the number type somewhere:

  typedef std::complex<double> Complex;
  // ...
  auto func = [] (Complex z, Complex c) { return z * z + c; };
I think that last one looks ok.
Re:Mandelbrot set in C++11 by creatio on Thursday February 28, 2013 @10:03AM (#5298910)
I thought I've read somewhere that they are working for a lambda ala C# style. Can't find the paper though.

Edit: I found the following links concerning this topic:

http://root.cern.ch/drupal/content/c14 http://isocpp.org/blog/2012/12/an-implementation-of-generic-...

And the paper: http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3418.pd...

Re:Mandelbrot set in C++11 by mikeash on Thursday February 28, 2013 @10:07AM (#5298934)
Maybe we have different aesthetic objections, but isn't all of the ugliness in that example due to the templated std::complex class, and unrelated to lambdas? If you make a typedef first, it becomes considerably nicer:

auto func = [](cdouble z, cdouble c) -> cdouble { return z * z + c; }