On Tuesday, 12 February 2013 at 14:10:41 UTC, Jacob Carlborg wrote:
On 2013-02-12 13:08, Era Scarecrow wrote:
No, deducing types like this won't work for static typing, be they anonymous or not. The only way they'd work is if they only existed for the one instance, being point or point_color, but auto wouldn't allow you to auto determine it; But still that doesn't seem like a good syntax to have and I'd rather take the extra line to define the type to ensure it's uniqe, Or tuples if it's only data..

You obviously don't understand how I want it to work.

Seems I did misread what you had, however having it creating dozens of misc/anonymous types doesn't seem like a wise idea. The entire block as it was defined is more like a scope/code block rather than a struct declaration; Then is it a delegate instead? (without return type or input type possibly)

  int x = 100;
  int y = {
      int z;
      int isPrime(int n);

      z = x * 100;
//      z = isPrime(100); //alternate to avoid 'nested'
  };

  //was code block run? (delegate or anonymous function)
  assert(y.z == 10000);
  writeln(y.z);          //allowed?
  writeln(y.isprime(x)); //allowed?
  y();                   //allowed?

  //if y is code block can be run...
  //last line is return line? Or not?
  assert(y() == x*100);
//  assert(y() == 0);      //isprime version

Now if it relies on x or not, is it now nested or not? Keep in mind the following is completely legal in C/C++/D. I've used this before to help separate and fold code.

 {
   //inner scope
   {
     int tmp = 256;
     //some code involving tmp
   }
 }

Reply via email to