Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: [PC] Simple AST Date: Wed, 06 Mar 2019 08:34:01 -0800 Organization: A noiseless patient Spider Lines: 49 Message-ID: <86ef7kufly.fsf@mailhub.linuxsc.com> References: <28f4e80d-4ff5-44d3-bdec-eb593f551575@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="e15454bde2a12f49e7459b0851635e02"; logging-data="6896"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1ghB6BCDWAOhX6B8o9eegoU83BLV70+8=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:UG4J4sSCMUrNZMI8sKAL2xxpBnc= sha1:3wkhRGMfKfFd6Cq6LQkMlKc5bfo= Xref: csiph.com comp.lang.c:141730 "Pascal J. Bourguignon" writes: > Rosario19 writes: > >> [..concerning whitespace in program source..] >> >> one program language without white spaces has readability == 0 > > Not really. If you can still use tab for indents, you're ok. > > int main(){ > int a=42; > int b=33; > if((a printf("less\n");} > else{ > printf("more\n");} > return(0);} > >> the true because program now are more readable it is not because >> they invent loop instructions (for break ecc) and structural >> instructions but main, because **indentation** and visual >> rememeber of loop and using indentation and spaces for show >> rendundance in the code... > > Don't use spaces other than where required to separate tokens, and > for indentation (spaces pay more than tabs). But don't use them > in expression: they're misleading! > > a = b+c * d; // spaces fail all the time. > > Instead, use parentheses: > > a=(b+(c*d)); This advice has it exactly backwards. For visual separation, spaces are better than parentheses because they are a better match to human perceptual hardware. For semantic grouping, variable spacing is better than parentheses, both because it is more readily perceived, and because it offers a redundancy that can be used as a check on what the author intended. The "misleadingness" in the example (and other similar examples) can be programmatically detected, and provides a tipoff that there is something wrong - either a misunderstanding on the part of the author, or a mistake in the algorithm, or perhaps both. Using spacing to (redundantly) show grouping adds useful information. Taking out all spaces and putting in redundant parentheses takes away information that is often useful - a losing proposition all the way around.