Python syntax in Lisp and Scheme

Pascal Bourguignon spam at thalassa.informatimago.com
Thu Oct 16 00:08:10 EDT 2003


mertz at gnosis.cx (David Mertz) writes:

> Joe Marshall <jrm at ccs.neu.edu> wrote previously:
> |it is *not* hard to see that they exist, nor hard to see if two
> |adjacent ones are the same or different, but that it *is* hard to see
> |exactly how many of them are there in deeply indented code).
> 
> Here's a quick rule that is pretty damn close to categorically true for
> Python programming:  If you use more than five levels of indent, you are
> coding badly.  Something is in desperate need of refactoring.
> 
> I did a scan of my Gnosis Utilities, which the tool SLOCCount' reports
> as having about 7500 lines of Python code.  Using a quick custom script,
> I find that I use more than depth five a total of four times--all of
> them within a class definition.  Maybe that means I should do a little
> refactoring, but even five levels is pretty unusual.
> 
> Visually distinguishing among four or five possible indent levels is
> extremely easy.  The nonsensical non-problem about indecipherable
> indents just simply never happens in useful code.
> 
> Yours, David...

Here is an histogram of the depths  of the top level sexps found in my
emacs sources:

((1 . 325) (2 . 329) (3 . 231) (4 . 163) (5 . 138) (6 . 158) (7 . 102)
 (8 . 94) (9 . 63) (10 . 40) (11 . 16) (12 . 20) (13 . 9) (14 . 4) 
 (15 . 5) (16 . 4) (17 . 2) (19 . 2) (23 . 1))

Am I depraved in writting code with depths down to 23?

Ok, in Python, you may  have also expressions that will further deepen
the tree,  but how can  you justify an artificial  segregation between
indentation and sub-expressions?

-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.




More information about the Python-list mailing list