Date: Sun, 21 Apr 2024 08:15:10 +1000
On Sun, Apr 21, 2024 at 8:04 AM Tiago Freire <tmiguelf_at_[hidden]> wrote:
> Just a small observation,
> 'if(!' doesn't mean the whole statement is negated.
> if(!a &&b) cannot be replaced with if!
> so be careful with that.
>
You missed my second PSS. I checked that. Estimate. 95%+ of `if(!` are
`if(!expr)`. Things like `if(!a && !b)` are in the minority.
> Plus, it's only relevant if there's no accompanying else (otherwise just
> swap the order of the branches)
>
That's unclear. Sampling that is harder to work out. At least a majority
doesnt have else branches.
Plus a lot of them are in if-else-chains, so what would it mean to "swap
the order of the branches" in an if-else-chain, which branches? Its not so
simple.
Not that it matters, nobody is going to back and change the code that's
> already written to if! in order to save 2 characters, storage space is not
> an issue at this level.
>
> And I agree with Jens, it's a wart, doesn't actually make my life easy, it
> just adds another extra rule that I didn't need to the list of things I
> have to learn. Just put the 2 parentheses, there's already a syntax to
> negate expressions, we don't need one to negate keywords.
>
Dunno. I think `unless` is a better idea than `if!(expr)`, whether either
is better than the status quo is unclear. All I'm noting is that
`if(!expr)` is shockingly common.
-Andrew
> Just a small observation,
> 'if(!' doesn't mean the whole statement is negated.
> if(!a &&b) cannot be replaced with if!
> so be careful with that.
>
You missed my second PSS. I checked that. Estimate. 95%+ of `if(!` are
`if(!expr)`. Things like `if(!a && !b)` are in the minority.
> Plus, it's only relevant if there's no accompanying else (otherwise just
> swap the order of the branches)
>
That's unclear. Sampling that is harder to work out. At least a majority
doesnt have else branches.
Plus a lot of them are in if-else-chains, so what would it mean to "swap
the order of the branches" in an if-else-chain, which branches? Its not so
simple.
Not that it matters, nobody is going to back and change the code that's
> already written to if! in order to save 2 characters, storage space is not
> an issue at this level.
>
> And I agree with Jens, it's a wart, doesn't actually make my life easy, it
> just adds another extra rule that I didn't need to the list of things I
> have to learn. Just put the 2 parentheses, there's already a syntax to
> negate expressions, we don't need one to negate keywords.
>
Dunno. I think `unless` is a better idea than `if!(expr)`, whether either
is better than the status quo is unclear. All I'm noting is that
`if(!expr)` is shockingly common.
-Andrew
Received on 2024-04-20 22:15:22