Along these lines, Go eliminates many formatting decisions at the syntax level. E.g., func main() { fmt.Println("HELLOWORLD") } is not just non-standard formatting, but illegal Go syntax. Similarly, extra parentheses around if clauses are not allowed.
> Similarly, extra parentheses around if clauses are not allowed. However 'if (x) == (1) {}' is totally fine with the formatter. As is an assignment of '(x) = (y)'. It's actively annoying too because like, extra parenthesis often have important meaning. For example, consider the following code: if (x.isFoo() || x.isBar()) /* && x.isBaz() */ { /* code */ } In that case, the code is obviously temporarily commented out,…
Formatting code should be unnecessary
461–470 of 484 posts
Re: Formatting code should be unnecessary
#462Along these lines, Go eliminates many formatting decisions at the syntax level. E.g., func main() { fmt.Println("HELLOWORLD") } is not just non-standard formatting, but illegal Go syntax. Similarly, extra parentheses around if clauses are not allowed.
> Similarly, extra parentheses around if clauses are not allowed. However 'if (x) == (1) {}' is totally fine with the formatter. As is an assignment of '(x) = (y)'. It's actively annoying too because like, extra parenthesis often have important meaning. For example, consider the following code: if (x.isFoo() || x.isBar()) /* && x.isBaz() */ { /* code */ } In that case, the code is obviously temporarily commented out,…
Re: Formatting code should be unnecessary
#463Earlier quoted context omitted.
Define high? I think 120 is pretty reasonable. Maybe even as high as 140. Log statements however I think have an effectively unbounded length. Nothing I hate more than a stupid linter turning a sprinkling of logs into 7 line monsters. cargo fmt is especially bad about this. It’s so bad.
100 is the sweet spot, IMO. I like splitting long text as in log statements into appropriate source lines, just like you would a Markdown paragraph. As in: logger.info( "I like splitting long text as in log statements " + "into ” + suitablelAdjective + " source lines, " + "just like you would a Markdown paragraph. " + "As in: " + quine); I agree that many formatters are bad about this, like introducing an indent for…
Re: Formatting code should be unnecessary
#464Earlier quoted context omitted.
Formatters eliminating long lines is a pet peeve of mine. About once every other project, some portion of the source benefits from source code being arranged in a tabular format. Long lines which are juxtaposed help make dissimilar values stand out. The following table is not unlike code I have written: setup_spi(&adc, mode=SPI_01, rate=15, cs_control=CS_MUXED, cs=0x01); setup_spi(&eeprom, mode=SPI_10, rate=13, cs_co…
Those kind of tables improve readability right until someone hits a length constraint and had to either touch every line in order to fix the alignment, causing weird conflicts in VCS, or ignore the alignment and it's slow decay into a mess begins.
Re: Formatting code should be unnecessary
#465Earlier quoted context omitted.
setup_spi( &adc, mode=SPI_01, rate=15, cs_control=CS_MUXED, cs=0x01 ); setup_spi( &eeprom, mode=SPI_10, rate=13, cs_control=CS_MUXED, cs=0x02 ); setup_spi( &mram, mode=SPI_10, rate=50, cs_control=CS_DIRECT, cs=0x08 ); ftfy
This is good, and objectively better than letting the random unbounded length of the function name define and inflate and randomize the indentation. It also makes it easier to use long descriptive function names without fucking up the indentation. setup_spi(&adc, mode=SPI_01, rate=15, cs_control=CS_MUXED, cs=0x01 ); setup_spoo(&adc, mode=SPI_01, rate=15, cs_control=CS_MUXED, cs=0x01 ); setup_s(&adc, mode=SPI_01, rate…
setup_spi(
&adc,
mode = SPI_01,
rate = 15,
cs_control = CS_MUXED,
cs = 0x01 );
setup_spoo(
&adc,
mode = SPI_01,
rate = 15,
cs_control = CS_MUXED,
cs = 0x01 );
setup_s(
&adc,
mode = SPI_01,
rate = 15,
cs_control = CS_MUXED,
cs = 0x01 );
validate_and_register_spi_spoo_s(
&adc,
mode = SPI_01,
rate = 15,
cs_control = CS_MUXED,
cs = 0x01 );Re: Formatting code should be unnecessary
#466Earlier quoted context omitted.
> I've never understood why people care so much about the linter settings. Source code formatting programs are not the same as lint[0] programs. The former rewrites source code files such that the output is conformant with a set of layout rules without altering existing logic. The latter is a category of idempotent source code analysis programs typically used to identify potential implementation errors within otherwi…
Thank you! I am almost going out of my mind reading this ~200 comment thread with everyone just casually saying "linter" when they mean "formatter". Do people really not distinguish between these two very different programs?
Re: Formatting code should be unnecessary
#467Earlier quoted context omitted.
Thats a slippery slope towards storing semantics and displaying locally preferred syntax ;)
That's why Python should have gone all-in on significant spaces: tabs for blocks, spaces after tabs for line continuation
Re: Formatting code should be unnecessary
#468Re: Formatting code should be unnecessary
#469Earlier quoted context omitted.
Those kind of tables improve readability right until someone hits a length constraint and had to either touch every line in order to fix the alignment, causing weird conflicts in VCS, or ignore the alignment and it's slow decay into a mess begins.
so you're basically saying "look this is neat and I like it, but since we cannot prevent some future chap come along and make a mess of it, let's stop this nonsense, now, and throw our hands up in the air—thoughts and prayers is what I say!"?
Re: Formatting code should be unnecessary
#470Earlier quoted context omitted.
That’s seems like a genious remark actually. If you store the abstract objects and have the mechanism to transform to whatever the desired output form is, it’s almost trivial to expose a version as files and text rendering for tools that are thus oriented, isn’t it?
Originally my fathers idea from back in the 90s to create a language with a whole suite of syntactic representations to suit your preferences. Want it to look like C? Lisp? Pascal? Why not!