On Tue, Jun 14, 2016 at 01:45:10PM +0930, Paul 'Rusty' Russell wrote:
> Dan Good <d...@dancancode.com> writes:
> > Hi David,
> >
> > I'm back home in front of a real keyboard, and want to follow up with you
> > about your patches.  I must admit that my usual practice is to use NULL,
> > and not 0.  Around the time I wrote altstack I had recently read Jen
> > Gustedt's book, Modern C.  In it, he makes the point that NULL hides more
> > than it clarifies (see section 11.7).
> 
> (I don't really care: your code, your style).  But...
> 
> He is so horrifically wrong, it's amazing.
> 
> Section 7.17 is loosened from ANSI C which said NULL was 0, presumably
> to *allow* compilers to avoid the varargs issue.  A compiler *could* do
> insane shit to make that problem even worse, but you would never use
> such a compiler.  There are other legal-but-insane things a compiler can
> do, too, and the answer is the same; real code won't work, nobody else
> cares.
> 
> OTOH, using 0 in place of NULL makes for much more potential type order
> confusion.  Not to mention confusing every damn C programmer on the
> planet.

Yeah.  I can kind of see the hint of a good idea in those articles,
but on balance they're really not convincing.  Basically, as Rusty
says, matching the conventions of the huge bulk of existing C code
outweighs the value of working with a compiler/library that has gone
out of its way to implement this stupidly.

> Note, I also assume NULL is all zero-bits,

I try to avoid that one, although I can't be sure I always have - I'm
not sure, but I think one of the s390 variants might break this.

> that size_t can hold a
> ptrdiff_t,

Dunno if I've assumed that much.

> and that a pointer to a function which takes a type *
> argument can be cast and called as a function which takes a void *.

Yeah, I've used that.

> If someone ports CCAN to a platform where those are not true, I'd be
> fascinated...

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

Reply via email to