Re: [RFC PATCH 1/5] builtin/checkout: avoid usage of '!!'

3 messages, 2 authors, 2017-09-20 · open the first message on its own page

Re: [RFC PATCH 1/5] builtin/checkout: avoid usage of '!!'

From: Junio C Hamano <hidden>
Date: 2017-09-20 04:00:32

Kaartic Sivaraam [off-list ref] writes:
There was a usage for which there's no compelling reason.So, replace
such a usage as with something else that expresses the intent more
clearly.
I actually think this is a good example of the exception-rule.  The
function wants to take true or false in "int", and the caller has a
pointer.  And !!ptr is a shorter and more established way than ptr
!= NULL to turn non-NULL ness into an int boolean, without having to
either repeat or introducing an otherwise unnecessary temporary.

Re: [RFC PATCH 1/5] builtin/checkout: avoid usage of '!!'

From: Kaartic Sivaraam <hidden>
Date: 2017-09-20 08:10:09

On Wednesday 20 September 2017 09:30 AM, Junio C Hamano wrote:
Kaartic Sivaraam [off-list ref] writes:
quoted
There was a usage for which there's no compelling reason.So, replace
such a usage as with something else that expresses the intent more
clearly.
I actually think this is a good example of the exception-rule.  The
function wants to take true or false in "int", and the caller has a
pointer.  And !!ptr is a shorter and more established way than ptr
!= NULL to turn non-NULL ness into an int boolean, without having to
either repeat or introducing an otherwise unnecessary temporary.
Though !!ptr might might be a shorter way to turn a pointer into an
int boolean I think the documentation says pretty well why we
shouldn't be using it,

         "..  can be extremely confusing to others".

Should I drop this treating is an exception rule (or) should I keep this
back?

Thanks,
Kaartic

Re: [RFC PATCH 1/5] builtin/checkout: avoid usage of '!!'

From: Kaartic Sivaraam <hidden>
Date: 2017-09-20 11:26:59

Wait, I missed a contradiction here.

On Wednesday 20 September 2017 09:30 AM, Junio C Hamano wrote:
....  And !!ptr is a shorter and more established way than ptr
!= NULL to turn non-NULL ness into an int boolean,
Documentation/SubmittingPatches says:
 - Some clever tricks, like using the !! operator with arithmetic
   constructs, can be extremely confusing to others.
If !!ptr is a **more established way** to then why should it confuse 
others. Of course,
!!ptr was stated as an "exception-rule" where ptr is a pointer (possibly 
NULL). That makes
me wonder in what case is it "confusing" at all?

---
Kaartic
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help