[Python-Dev] .clinic.c vs .c.clinic

Larry Hastings larry at hastings.org
Sat Jan 18 19:49:39 CET 2014

On 01/18/2014 01:02 AM, Serhiy Storchaka wrote:
> 1. I very very often use global search in sources. It's my way of navigation
> and it's my way of investigations. I don't want to get false results in
> generated files. And it is much easy to specify mask '*.[ch]' or '*.c,*.h'
> (depending on tool) than specify a mask and negative mask. The latter is even
> not always possible, I can write cumbersome expression for the find command,
> but Midnight Commander doesn't support negative masks at all (and perhaps your
> favorite IDE doesn't support them too).

Apparently you do this at the command-line.  In that case, you can make 
an 'alias' to hide the cumbersome expression. Perhaps you've already 
made one that ignores the ".hg" directory tree?

If the generated file didn't end in a standard extension, editors won't 
automatically recognize them and won't code-color them.  You tell me 
"everyone can easily reconfigure their editors" but it seems you writing 
an alias is unreasonable.

> 2. I'm not use any IDE, but if you use, it can be important for you. If IDE
> shows sources tree, unlikely you want to see generated *.clinic.c files in
> them. This will increase the list of sources almost twice.

My experience is that IDEs either show all files in the "project" (which 
should include the generated files anyway) or they show all files in the 
directory.  So this concern assumes behavior that isn't true.

> 3. Pathname expansion works better with unique endings, You can open all
> Modules/_io/*.c files, but unlikely you so interested in *.clinic.c files which
> are matched by former pattern.

How often do people edit *.c in a directory?  And then, how often do 
people edit *.c in a directory and wouldn't want to see the Argument 
Clinic generated code?

> 4. .c suffix at the end lies. This is not compilable C source file. This file
> should be included in other C source file. This will confuse accidental user
> and other tools. Including Argument Clinic itself, this is why it inserts the
> "preserve" directive at the start of generated file. But other tools have no
> such sign.

This is nonsense.  The contents of the file is 100% C.  If you added the 
proper include files (by hand, not recommended) it would compile standalone.

A lot of your suggestions assume no one would ever want to examine the 
generated code.  But people will still want to look in there:

  * to set breakpoints
  * to make sure existing Argument Clinic generated code does what you
  * when experimenting with Argument Clinic inputs

So I don't see the need to make the generated files totally invisible.

Later in the thread someone suggests that ".h" would be a better ending; 
I'm willing to consider that.  (As in ".clinic.h".)  After all, you do 
include it, and there's some precedent for C code in H files (the 
already-cited stringlib).

Also, now I'm starting to worry that adding ".clinic.c" files to an IDE 
would mean the IDE would try to compile them.  Can somebody who uses an 
IDE to compile Python code experiment with ".clinic.c" files and report 
back--is it possible to add them to your "project" in such a way that 
the compiler will notice when they changed but won't try to compile them 
standalone?  I'm thinking specifically of MSVS, as that's explicitly 
supported by CPython, but I'm interested in results from other IDEs if 
people use them with CPython trunk.

Serhiy: I appreciate your contributions, both to Python in general and 
to Argument Clinic specifically.  And you're only doing this because you 
care.  Still, I feel like you've never been shown a bikeshed you didn't 
have an opinion on.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140118/64458fc3/attachment.html>

More information about the Python-Dev mailing list