« Return to Thread: Another formatting question: function types

Re: Another formatting question: function types

by Blair Zajac :: Rate this Message:

Reply to Author | View in Thread

1. With spaces.
2. Without parens.
3. We need to figure out keyword and default argument formatting.  The Python
style guide PEP-8 has no spaces around default arguments.

http://www.python.org/dev/peps/pep-0008/

     - Don't use spaces around the '=' sign when used to indicate a
       keyword argument or a default parameter value.

       Yes:

           def complex(real, imag=0.0):
               return magic(r=real, i=imag)

       No:

           def complex(real, imag = 0.0):
               return magic(r = real, i = imag)

Blair

Bill Venners wrote:

> Hi All,
>
> I wanted to take the community's temperature on how they prefer to see
> function types formatted. I have three questions.
>
> 1. Do you want spaces around the => or not? Here is with spaces:
>
> (String, Int) => Unit
>
> Here is without:
>
> (String, Int)=>Unit
>
> 2. If a type has arity 1, do you want parens around it or not? Here it
> is with parens:
>
> (String) => Unit
>
> Here it is without:
>
> String => Unit
>
> 3. Lastly, anything else you like to see?
>
> Thanks.
>
> Bill
> ----
> Bill Venners
> Artima, Inc.
> http://www.artima.com
>

 « Return to Thread: Another formatting question: function types