🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #8883

Re: indentation style

#8883
From: Glenn Reid
Date: Mon, 05 Feb 1990 23:54
77 lines
3321 bytes
In article <17867@rpp386.cactus.org> woody@rpp386.cactus.org (Woodrow Baker) writes:
>p.s.  You should also get the GREEN book.  It has a LOT of things to say
>about this and other topics.  It really is a philosophy book about
>programming.  Glenn did an excellent job on it.

Thank you.

>						  However, I don't
>recommend following his brace style, as it is a bit hard to read.

I have to take issue with you.  Here's what you wrote:

	stuff{
	asdfasdfasdff
	asdfasdfsadf
	} def
	^^^^^^^^^^^^^^^^^^NONO.

	stuff
		{
		asdfasdfasfd
		asdfasdfffdadsf
		} def
	^^^^^^^^^^^^^^^^^^^Much easier to see.  You are started on the right
	format.


The first was supposed to represent my indentation style, but doesn't.  It
isn't indented at all, in fact.  Even if one were to put the opening
brace on a line by itself, as you propose, you still have the indentation
wrong.  Here are the two styles that I recommend, the first one slightly
preferable, to me, because it saves one vertical line in the program.
Readability also has to do with how much of a given context you can see at
once without scrolling, and vertical spacing has a lot to do with that;
the second sample is what I think yours should have looked like, since the
code inside the braces is what should be indented, not the braces themselves.

	% sample 1:

	/stuff { %def
		asdfasdfasdff
		asdfasdfasdf
	} def


	% sample 2 (which yours should have been):

	/stuff
	{
		asdfasdfasdf
		asfasfasdfasf
	} def


Indentation has semantic meaning.  It means, roughly "everything indented
the same amount is at the same structural level."  In the case that you
show, the name "stuff" (you forgot the slash, by the way) is at the same
level as the procedure body, which you indent.  I find that very hard to
read, since "stuff" is now hanging out on the left all by itself.  It gets
worse when you nest them several deep.

The other thing that is important in indentation style is to be able to
easily skip past an entire context, from open to close, by just looking
vertically down a column.  I think that all of these techniques do pretty
well at that, although I have a natural preference for my own style :-)

Also, recognizing that this is "stylistic" is very important.  You claim
that mine is "hard to read", but you don't offer any reasons for that,
other than that you can't read it.  In the Green Book there is a modest
amount of explanation of the indentation style and the rationale behind
it in the Introduction somewhere.  And, of course, if you want to take
issue with it on the net, that's fine, but please say something substantive,
other than it should be done like anyone would indent Pascal, and please
at least get the stuff right that you are critiquing.

Thanks,
 Glenn Reid
Technical Details
Message-ID: <133@heaven.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!adobe!heaven!glenn
References: <17807@rpp386.cactus.org> <9002040147.AA16999@en.ecn.purdue.edu> <17867@rpp386.cactus.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!adobe!heaven!glenn
From: glenn@heaven.woodside.ca.us (Glenn Reid)
Newsgroups: comp.lang.postscript
Subject: Re: indentation style
Message-ID: <133@heaven.COM>
Date: 5 Feb 90 23:54:33 GMT
References: <17807@rpp386.cactus.org> <9002040147.AA16999@en.ecn.purdue.edu> <17867@rpp386.cactus.org>
Reply-To: glenn@heaven.UUCP (Glenn Reid)
Organization: Glenn Reid (at home), NeXT, Inc.
Lines: 77