Nested ternaries are fairly readable in JavaScript these days due to the
use of Prettier for code formatting.
gofmt could do the same.
For example, this:

lc_unicodeliterals = quote=='u' ? 1 : quote=='U' ? 0 : !!(ast.locale.set &
AST_LC_unicodeliterals);

could be formatted to this:

lc_unicodeliterals =
  quote == 'u' ? 1 :
  quote == 'U' ? 0 :
  !!(ast.locale.set & AST_LC_unicodeliterals);

On Wed, Apr 24, 2019 at 4:02 PM Kurtis Rader <kra...@skepticism.us> wrote:

> On Wed, Apr 24, 2019 at 1:14 PM andrey mirtchovski <mirtchov...@gmail.com>
> wrote:
>
>> Here's the lore associated with the subject: Ken wanted ternary, Rob
>> and Robert did not. They overruled Ken (remember, early on all three
>> had to agree for a feature to go in). The end.
>>
>> The number of frivolous and egregious abuse of ternary that I've seen
>> in _modern_ C code is too high.jpg
>>
>
> +100 to that sentiment. While the brevity of a ternary expression
> is  useful for trivial cases it tends to be abused. For your
> amusement/horror here are just a few, of a couple hundred, examples of
> ternary being abused in the AT&T AST (which includes ksh) source:
>
>
> https://github.com/att/ast/blob/e770c77e9816e156c6df4a455e71b5f9fff79310/src/cmd/ksh93/edit/hexpand.c#L447
>
>
> https://github.com/att/ast/blob/e770c77e9816e156c6df4a455e71b5f9fff79310/src/cmd/ksh93/sh/string.c#L344-L346
>
>
> https://github.com/att/ast/blob/8504cd407846d192881a94d507333697f016a85a/src/lib/libast/include/sfio.h#L359-L360
>
>
> https://github.com/att/ast/blob/8504cd407846d192881a94d507333697f016a85a/src/lib/libast/include/cdt.h#L313-L316
>
>
> https://github.com/att/ast/blob/e770c77e9816e156c6df4a455e71b5f9fff79310/src/lib/libz/deflate.c#L597-L609
>
> For those who don't want to follow those links this is the code from the
> first URL above:
>
> lc_unicodeliterals = quote=='u' ? 1 : quote=='U' ? 0 : !!(ast.locale.set &
> AST_LC_unicodeliterals);
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>


-- 
R. Mark Volkmann
Object Computing, Inc.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to