On Tuesday, 11 September 2012 at 17:52:44 UTC, Jonathan M Davis wrote:
On Tuesday, September 11, 2012 19:37:02 monarch_dodra wrote:
However, when written like this:

struct C(T)
{
      private T val;

      // Gets front
      @property T front()
      {val = value;}

      //Writes to front
      static if(isAssignable!(T,T))
      @property void front(T value)
      {val = value;}
}

Then I think it reads alright.

Whereas I think that that hards readibility, because it hides the fact that a static if is used. If you're submitting code for Phobos, please do something
like

static if(isAssignable!(T, T)) @property void front(T value) {val = value;}

or

static if(isAssignable!(T,T))
    @property void front(T value) { value = value; }

rather than what you have above, otherwise it will harm maintainability.

- Jonathan M Davis

Hum... Yeah, you are kind of right.

I actually am committing something, but the code is a 2 liner. (enforce, then assignment).

Is one of these what you are suggesting?

//One
static if(isAssignable!(T,T)) @property void front(T value)
{
    enforce(someCondition)
    value = value;
}

or

//Two
static if(isAssignable!(T,T))
    @property void front(T value)
{
    enforce(someCondition)
    value = value;
}

or

//Three
static if(isAssignable!(T,T))
@property void front(T value)
{
    enforce(someCondition)
    value = value;
}


(or just plain)

//Four
static if(isAssignable!(T,T))
{
    @property void front(T value)
    {
        enforce(someCondition)
        value = value;
    }
}

Which do YOU think reads best in this case? That the style I'll use in my submit.

I like //Three because it reads like an attribute.

Of course, I have no problem submitting it with the default //Four if you think that is best. I'm just trying to do as best possible.

Reply via email to