Paren Padders, how do you like to see parens padded?

I do not pad parens, but I am adding the option to my format code (a better replacement for Standardize Format). I understand simple cases such as:

SayHello( "World" )

But what do you paren padders do with something like:

 a = ((b * Abs(c)) / d)

Would that wind up looking like:

a = ( ( b * Abs( c ) ) / d )

?

Personally, I prefer one space between a function name and the left parenthesis.

doMyThing (parameter) myResult = MyThingDone (parameterlist)

Other than that, I prefer not having padded parentheses, not even for arrays.

BTW, for what it’s worth, I prefer one space after each comma in a parameter list.

myResult = MyThingDone (parameter1, parameter2, whateverelse)

But that’s just my preference; I also prefer dark chocolate over milk chocolate.

I agree with dale (apart from the chocolate)

personally I prefer no extra whitespace

myResult=MyThingDone(parameter1,parameter2,whateverelse)

but part of that probably comes from days when white space consumed precious memory, and it was too valuable to waste :slight_smile:

[quote=22221:@Jeremy Cowgar]Would that wind up looking like:

a = ( ( b * Abs( c ) ) / d )
[/quote]

Yes, that’s exactly what my code would look like. I find it easier to read and track that way.

I’d go with:
a = (b * Abs©) / d

the outer pair of parenthesis are not required :slight_smile:

Then this would make a better example:

a = ( ( b * Abs( c ) ) / d ) + 1

In that case, I’d go with:

a = ((b * Abs©) / d) + 1

Or maybe:

a = ((b * Abs©) / d) + 1.0

:stuck_out_tongue:

In this case I wouldn’t go with the outer parenthesis unless I was performing another operation on ( b * Abs( c ) ) / d , whats the need?

I think you’re both missing the point of the original question. :slight_smile:

[quote=22221:@Jeremy Cowgar]I do not pad parens, but I am adding the option to my format code (a better replacement for Standardize Format). I understand simple cases such as:

SayHello( "World" )

But what do you paren padders do with something like:

 a = ((b * Abs(c)) / d)

Would that wind up looking like:

a = ( ( b * Abs( c ) ) / d )

?[/quote]
For me: Space on outside of parens only
a = (b + c) * d

No space between multiple sequential parens of the same type
a = ((b + c) * (d - (e / f)))

Currently, Format Code does things like this:

dim a as integer=20*((3            +4)+abs(c))
for i as integer=0 to 90
    DoSomething
next
Dim a As Integer = 20 * ((3 + 4) + abs(c))
For i As Integer = 0 To 90
    DoSomething
Next

(and a whole lot more corrective actions).

You can then set some parameters at the top such as: PadParens = True CaseConversion = kUpperCase

and the above will turn out as

DIM a AS INTEGER = 20 * ( ( 3 + 4 ) + abs( c ) )
FOR i AS INTEGER = 0 TO 90
    DoSomething
NEXT

There is also kLowerCase and kTitleCase. Seems that I need to rethink my PadParens option and two, PadInnerParens and PadOuterParens then it will be configurable to fit most peoples coding standards. One did mention having no spacing anywhere, I could provide an option NoSpace but I wonder how many people would use it?

Spaces between operators and operands, parentheses around the parameters of methods, no spaces between method names and the opening parenthesis, no spaces between nested parentheses:

a = ((b * Abs(c)) / d) + 1

All other styles are evil and wrong, of course :wink:

[quote=22330:@Andrew L.]Spaces between operators and operands, parentheses around the parameters of methods, no spaces between method names and the opening parenthesis, no spaces between nested parentheses:

a = ((b * Abs(c)) / d) + 1

All other styles are evil and wrong, of course ;)[/quote]

That’s how it works right now, I call that “Standard” formatting, so I’m with ya :smiley:

Oh, and spaces between parameters to a method (after the comma, of course):

Sub Foo(Param1 As Integer, Param2 As Integer, Param3 As Integer)

That’s the way I like it too.

You guys would hate my code. I do love my spaces. :slight_smile:

Within reason, I’d like to make Format Code handle a variety of options. So, post a snippet of some code showing how you format. I’m not sure you can get more spacey than:

a = ( ( Abs ( x + 20 ) * 18 ) / 12 ) + 2 + Floor ( y )

? i.e.

PadOperators = True PadInnerParens = True PadOuterParens = True

Well, you could do assignment alignment and also inline comment alignment, which I am planning to support

AssignmentAlign     = Bitwise.BitAnd(kAs, kEqualSign) // Could also be kNone, kEqualSign and kAs
InlineCommentColumn = 40

Dim a         As Integer = 20
Dim lastName  As String  = "Doe"
Dim firstName As String  = "John"

a = a + 18                             // Add 18 to a
a += 18                                // Add 18 more to a

OK, from this thread I have finished up v1.0.0b1, please see: https://forum.xojo.com/3339-format-code-v1-0-0b1-xojo-script-to-nicely-format-