On Wed, Nov 26, 2014 at 4:30 AM, Gabe Black via gem5-dev <gem5-dev@gem5.org>
wrote:

>
>
> Just to make sure we're all on the same page, I removed the spaces here
> because these are default values for arguments. My brain might have just
> pattern matched and applied a rule for named function arguments in python
> we use at work, but, unless there's a policy against it, I still like the
> way it looks in this case. For other uses of "=" and other operators I
> think there should definitely be spaces.


I'm a little surprised to see that there's no mention of spacing around
operators on the wiki page.  Of course, we've been enforcing spacing around
operators (including assignment operators) anyway, and we should update the
style guide to reflect that.

I, at least, have also been treating '=' differently when used to bind
default parameter values, and consider spaces there to be at best optional
if not discouraged, though we don't have a hard rule against them.  I see
that the Google Python style does though:
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Whitespace

I'd be happy to follow the Google style guide on this and get rid of spaces
around '=' for default parameters. They also ban spaces for calls using
keyword arguments, which I think we also generally follow, but probably not
consistently either. I'd say if we're going to follow Google here we should
go all the way and do it for both cases.

I would also say that, if we're going to ban spaces for default parameters,
we should make this apply to C++ as well as Python for consistency.
Interestingly, Google doesn't have this policy, because their C++ style
guide generally disallows default parameters in C++ to begin with:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Default_Arguments

Just to put a stake in the ground, I added the following two bullets under
http://gem5.org/Coding_Style#Spacing:


   - *one* space around binary operators (+, -, <, >, etc.) including
   assignment operators (=, +=, etc.)
   - *no* space around '=' when used in parameter/argument lists, either to
   bind default parameter values (in Python or C++) or to bind keyword
   arguments (in Python)


I'm happy to edit/remove them if there's disagreement, but I figured this
would give something concrete and concise to discuss.

Steve
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to