Re: Coding style in CPython implementation

2017-10-30 Thread Rhodri James
On 28/10/17 19:42, Στέφανος Σωφρονίου wrote: Greetings everyone. I have noticed that in many if conditions the following syntax is used: a) if (variable == NULL) { ... } b) if (variable == -1) { ... } c) if (variable != NULL) { ... } What I wanted to ask is, is there a particular reason for no

Re: Coding style in CPython implementation

2017-10-29 Thread Στέφανος Σωφρονίου
On Monday, October 30, 2017 at 2:35:13 AM UTC+2, ROGER GRAYDON CHRISTMAN wrote: > NOTE: The case in question was never comparing to True; it was comparing to > NULL. > > There is no "No: if x == None" below, because None is not Boolean. > Similarly comparing a pointer to NULL is not the same as

Re: Coding style in CPython implementation

2017-10-29 Thread ROGER GRAYDON CHRISTMAN
NOTE: The case in question was never comparing to True; it was comparing to NULL. There is no "No: if x == None" below, because None is not Boolean. Similarly comparing a pointer to NULL is not the same as comparing it to a Boolean. So I would favor the "Explicit is better than Implicit" in th

Re: Coding style in CPython implementation

2017-10-29 Thread Chris Angelico
On Mon, Oct 30, 2017 at 12:47 AM, Stefan Ram wrote: > =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= > writes: >>I guess the following parts from "Zen of Python" apply to this case: > > If we would agree to apply Python rules to C, > then we could also use this excerpt from PEP

Re: Coding style in CPython implementation

2017-10-29 Thread Rick Johnson
On Sunday, October 29, 2017 at 4:00:59 AM UTC-5, Στέφανος Σωφρονίου wrote: [...] > I guess the following parts from "Zen of Python" apply to this case: > > - Beautiful is better than ugly. > - Explicit is better than implicit. > - Simple is better than complex. > - Readability counts. Now go

Re: Coding style in CPython implementation

2017-10-29 Thread Στέφανος Σωφρονίου
On Sunday, October 29, 2017 at 4:18:38 AM UTC+2, Dan Sommers wrote: > On Sat, 28 Oct 2017 16:20:54 -0700, Στέφανος Σωφρονίου wrote: > > > I do believe though that if (!d) is a lot clearer than if (d == NULL) > > as it is safer than falsely assigning NULL in d, by pure mistake. > > Having made my

Re: Coding style in CPython implementation

2017-10-28 Thread Dan Sommers
On Sat, 28 Oct 2017 16:20:54 -0700, Στέφανος Σωφρονίου wrote: > I do believe though that if (!d) is a lot clearer than if (d == NULL) > as it is safer than falsely assigning NULL in d, by pure mistake. Having made my living writing C code for a very long time, I always found if (!d) *harder* to r

Re: Coding style in CPython implementation

2017-10-28 Thread Στέφανος Σωφρονίου
On Saturday, October 28, 2017 at 9:54:30 PM UTC+3, bartc wrote: > On 28/10/2017 19:42, Στέφανος Σωφρονίου wrote: > > Greetings everyone. > > > > I have noticed that in many if conditions the following syntax is used: > > > > a) if (variable == NULL) { ... } > > b) if (variable == -1) { ... } > >

Re: Coding style in CPython implementation

2017-10-28 Thread Ned Batchelder
On 10/28/17 4:26 PM, Stefan Ram wrote: Ned Batchelder writes: On 10/28/17 3:00 PM, Stefan Ram wrote: =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= writes: What I wanted to ask is, is there a particular reason for not choosing definition of »NULL«. »NULL« is not part of the

Re: Coding style in CPython implementation

2017-10-28 Thread Ned Batchelder
On 10/28/17 3:00 PM, Stefan Ram wrote: =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= writes: What I wanted to ask is, is there a particular reason for not choosing I am not a CPython developer, but here are my 2 cents about the possibilities: if (variable == NULL) { ...

Re: Coding style in CPython implementation

2017-10-28 Thread Chris Angelico
On Sun, Oct 29, 2017 at 5:42 AM, Στέφανος Σωφρονίου wrote: > Greetings everyone. > > I have noticed that in many if conditions the following syntax is used: > > a) if (variable == NULL) { ... } > b) if (variable == -1) { ... } > c) if (variable != NULL) { ... } > > What I wanted to ask is, is ther

Re: Coding style in CPython implementation

2017-10-28 Thread bartc
On 28/10/2017 19:42, Στέφανος Σωφρονίου wrote: Greetings everyone. I have noticed that in many if conditions the following syntax is used: a) if (variable == NULL) { ... } b) if (variable == -1) { ... } c) if (variable != NULL) { ... } What I wanted to ask is, is there a particular reason for

Coding style in CPython implementation

2017-10-28 Thread Στέφανος Σωφρονίου
Greetings everyone. I have noticed that in many if conditions the following syntax is used: a) if (variable == NULL) { ... } b) if (variable == -1) { ... } c) if (variable != NULL) { ... } What I wanted to ask is, is there a particular reason for not choosing a) if (!variable) { ... } in place