[Toybox] [PATCH] nohup: use the same mode constant for open() and xcreate().

enh enh at google.com
Thu Feb 2 08:06:28 PST 2023


On Thu, Feb 2, 2023 at 3:16 AM Rob Landley <rob at landley.net> wrote:
>
>
>
> On 2/1/23 11:02, enh wrote:
> > On Tue, Jan 31, 2023 at 9:29 PM Rob Landley <rob at landley.net> wrote:
> >>
> >> On 1/31/23 22:57, enh wrote:
> >> > aye, but only if you're stuck with a compiler from the 1990s... even gcc has
> >> > warned about that for years :-P
> >> ...
> >> >     and the warning unless it has parentheses isn't a
> >> >     strong defense either because a&b || c also needs parentheses so they tend to
> >> >     happen...
> >>
> >> Thingy.
> >
> > yeah, but the cure for that readability problem is to use enough
> > parentheses that it's clear to both human and compiler.
>
> The fix is _more_ unnecessary parentheses?

if we humans are confused, by definition they're necessary. (given
that you can't fix the language at this point.)

> > (iirc most of
> > the more modern languages have continued to copy c's mess forward. i
>
> Ritchie admitted it should have gotten cleaned up circa 1974:
>
>   https://www.lysator.liu.se/c/dmr-on-or.html
>
> But since it _didn't_ it's at least been consistent for 50 years. :)

aye, but consistently confusing, which is why they _did_ fix it in golang :-)

> > think only Swift has made a serious effort to rationalize operator
> > precedence? oh, no, golang also appears to have the obvious simplified
> > "yeah, that's what humans think the precedence should be" precedence.)
> >
> >> >     Otherwise they're theoretically equivalent, so changing it to be the other way
> >> >     because it "looks wrong" otherwise... seems weird to me? It looks like it
> >> >     couldn't be an assignment. That's the point...
> >>
> >> I still think wanting comparison to look different from assignment isn't
> >> inherently weird...
> >
> > maybe, but this way of doing it is weird (there's a reason it's called
> > "yoda style" :-) ),
>
> By you. I'd never heard that before...
>
> The wikipedia page on it was created 9 years ago. I started doing it in... 1992,
> I believe?
>
> > and -- at the risk of encouraging you to go and
> > yoda-ify everything -- it's not like toybox _consistently_ uses this
> > style
>
> Because it works both ways? The operator doesn't care.
>
> > (in the same way that "use octal for permissions" is without
> > doubt the toybox style).
>
> Because chmod 655 works on the command line but you can't feed u+x into the
> system call.
>
> > a quick "grep fight" shows a majority of -1 comparisons are the right
> > way round rather than yoda style. so in addition to the extra
> > cognitive load of reading something that's backwards, even if you
> > _only_ read toybox and aren't switching between other projects, even
> > toybox requires you to switch back and forth.
>
> Because you're comparing two things.
>
> "I can only tell apples from oranges if I hold the apple in my left hand" is WEIRD.

but also not true for modern gcc or clang --- they'll both warn you if
you mess up.

> >> Rob
>
> Rob


More information about the Toybox mailing list