I appreciate all the helpful replies, but I've simplified things to what I belive is the core issue. In C++ (at the risk of becoming a heretic) the language allows me to do the following:

struct SnonParameterized
{
public:
   int t;
   float u;
   SnonParameterized(int tparam, float uparam);
};

SnonParameterized::SnonParameterized(int tparam, float uparam)
{
   t = tparam;
   u = uparam;
}

SnonParameterized snp(5, 3.303); // this compiles with Visual C++ 2010


===============================================================================

Now with D, I try (what I think is identical semantics) the following:


struct SnonParameterized
{
   int t;
   float u;
   this(int t, float u)
   {
      this.t = t
      this.u = u;
   }
}

SnonParameterized cnp(5, 3.303); // fails compile with Error: found 'cnp' when expecting ';' following statement

auto hi = SnonParameterized(5, 3.303);  // compiles of course.


I'm just trying to understand why D disallows the non-assignment syntax. Probably for a very good (and obvious) reason.

Reply via email to