Source Code Format Settings

Help index


This dialog allows for the formatting (pretty printer) parameters to be configured.

Basically, there are 2 major formatting styles:

  1. K&R (Kernighan & Ritchie) Style
  2. Lisp Style

Kernighan & Richtie Style

This style is used by more than 90% of all programmers and is based on the style used in the UNIX operating system's C programs. It is named after the original Unix authors. Its main difference to the other style is that opening and closing parentheses are each on a separate line from the enclosing statements or expressions. This makes inserting & deleting lines easy. You can also easily find a block's enclosing bracket, by moving down the cursor from the starting line's left column.
For example:
    ...
    someCondition ifTrue:[
	...
	[another condition] whileTrue:[
	    ...
	].
	...
	[
	    someCode
	] on:Error do:[
	    handlerCode
	]
    ]

Lisp Style

This style is used by the rest, and most Smalltalkers (but not the ST/X author!). The opening parenthesis is on the same line as the first statement of a block, and the closing parenthesis is appended to the last line. This usually makes the code slightly denser (1 line per block), but makes insertion/deletion of text to the beginning or end of a block a little more work.
    ...
    someCondition ifTrue:[
	...
	[another condition] whileTrue:[
	    ...].
	...
	[
	    someCode]
	on:Error do:[
	    handlerCode]]
The settings dialog allows for a quick change between these two styles.

Notice: all of ST/X has been written in the K&R style (with the exception of some imported code from friends and public domain sources). and is the favourite style used and accepted by the author. As it is mostly his task to fix bugs and maintain the code, and it makes a huge difference when code has to be read and understood, he highly recommends (actually demands) that tis style is used when code is to be brought into ST/X.

Automatic Code Formatting

If on, methods source code is formatted (pretty printed) automatically when a method's source is displayed.
For now, the formatter is not invoked on keyboard input; you can reformat a changed method source via the popup menu.
You may want to disable this, if you don't like the formatters output.

The formatter may be configured to either generate lisp-style or c-style block format.

Warning: the formatter is based on the BRFormatter code ported from the RefactoryBrowser package. Porting is still underway and there may be bugs especially with ST/X extended syntax. The original formatter completely lost any comment layout, which resulted in very ugly looking source code (and is probably one reason, why many people did not comment their code!). We tried to fix most of those issues (but who knows...). Use at your own risk, and check if you like the output. If not, indent your code manually.


Copyright © Claus Gittinger Development & Consulting, all rights reserved


Doc $Revision: 1.6 $ $Date: 2016/10/30 15:20:58 $