Checkstyle AvoidNestedBlocksCheck
Andrew Haley
aph at redhat.com
Thu Dec 8 16:04:41 UTC 2016
On 08/12/16 15:49, Doug Simon wrote:
>
>> On 8 Dec 2016, at 16:43, Andrew Haley <aph at redhat.com> wrote:
>>
>> On 08/12/16 15:40, Stefan Marr wrote:
>>> Can you give a name to the block?
>>>
>>> If so, it might improve readability to break out such blocks into methods consistently.
>>
>> This is hand-written assembly code. It's just a loop. All I'm doing
>> is looping over two strings, comparing them.
>
> Sounds like it could be refactored into an emitCompareStrings() method.
It *is* the emitCompareStrings() method. It requires some setup
before the loop body, and the loop body has one variable, its label.
I can make that label global.
>> If I make the label
>> global and remove the braces Checkstyle stops complaining, which is
>> what I've done. The code is now compliant and worse: it's much like
>> the equivalent x86 code.
>
> If you prefer the nested block, you can bracket it with:
>
> // Checkstyle: stop
> ...
> // Checkstyle: resume
OK, thanks.
> I’ve mostly found nested blocks useful in C++ in use with destructors.
I'm used to a highly-structured way of writing assembly language, with
labels only visible inside the blocks where they are used. I also use
braces to indicate nesting. It seems to me that structured
programming is just as valid in assembly language as any other
language.
Andrew.
More information about the graal-dev
mailing list