hpi-swa-teaching / poppy-print

A small, opinionated pretty printer for Squeak/Smalltalk (SWT22-02)
MIT License
7 stars 1 forks source link

Fundamental debate: Dot after last method statement? (Yes!) #10

Open LinqLover opened 3 years ago

LinqLover commented 3 years ago

It makes me cry if my methods do not always end with a dot unless the last statement is a return node ... 😢

tom95 commented 3 years ago

The arguments known to me are as follows:

Personally, I currently always omit dots for last statements, on both methods and blocks. The dot, for me, acts as a separator between visible statements.

I, however, do not have a very strong opinion here. I would leave the issue open for a bit for other people to voice their opinions and see if we can find a consensus on what should be adopted.

LinqLover commented 3 years ago

con/pro: blocks are difficult here. Following the logic that we introduce the separator because there is an invisible return following we do not place a dot in a block's last statement. If we follow the logic that only a return statement is not terminated by a dot, we should place a dot after a block's last statement.

My logic is a bit different here: There should be always exactly one dot, and if we consistently use a dot after each statement, this rule will always be satisfied, for instance:

initializeFoo

    foo := myArray at: 1 ifAbsent: [self error].

(By the way, this also matches common interpunctuation rules for quotations from British "logical" English or also German grammar. For American English, however, things are more complicated, so their grammar might be a worse reference ... 😅)

LinqLover commented 3 years ago

@tom95 Here is another argument for PRO: