[Style] getting started

This commit is contained in:
Matthias Felleisen 2010-10-21 11:10:08 -04:00 committed by Eli Barzilay
parent cf3c3a4a7f
commit dcd0fb7134
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,19 @@
#lang scribble/base
@title[#:tag "correct-maintain-speed"]{Basic Facts of Life}
Write code that is correct; maintainable; and fast. The ordering of this
adjectives is critical: correct is more important than maintainable;
maintainable is more important than fast; and fast is important to include,
because nobody wants to live with slow programs.
Code is correct.
Code is maintainable.
Code is fast.
The following suggestions are about creating maintainable and fast
code. The production of correct code is a project for life, and depends to
a high degree on reflection---i.e., thinking about what you are doing and
not just doing it.

View File

@ -0,0 +1,9 @@
#lang racket
; things to be shared among all sections of the style guide
(require (for-label racket)
scribble/manual)
(provide (for-label (all-from-out racket))
(all-from-out scribble/manual))

View File

@ -0,0 +1,28 @@
#lang scribble/base
@(require "shared.rkt")
@title{How to Program Racket}
@author{Matthias Felleisen, Matthew Flatt}
@; -----------------------------------------------------------------------------
Since 1995 PLT has grown from a handful of people who worked on/with the
repository to three dozen and more. In addition, Racekt is an open source
project, meaning other people study the code in the repository and use it
as an implicit guide to Racket programming. To manage the growth of the PLT
developer basis and to showcase good Racket coding, every contribution
should satisfy certain basic criteria.
This document spells out these criteria, and it is also a call for
improvements and suggestions for additional criteria. Like code, this
document lives and benefits from the "many pairs of eyes" effect of open
source. Code should be viewed by more than one person; a second person is
likely to catch mistakes and problems and hidden bugs. This document is
meta-code, and the same ideas apply. If you have suggestions, contact the
authors via email.
@; -----------------------------------------------------------------------------
@include-section["correct-maintain-speed.scrbl"]
@include-section["textual.scrbl"]

View File

@ -0,0 +1,57 @@
#lang scribble/base
@(require "shared.rkt")
@title{Textual Matters}
@; -----------------------------------------------------------------------------
@section{Indentation}
DrRacket indents code. Use it. If you wish to be a real friend of PLT, use
DrRacket all the time, and do request features and changes for things you
don't like.
Real friends of PLT use DrRacket to write their programs, and they don't
override DrRacket's indentation style. They accept it and leave it alone.
The resulting uniformity helps guide eyes.
@margin-note{Okay, okay. We are using emacs to write this guide.} Minor
friends of PLT use Emacs and/or vi(m). Nevertheless, these minor friends
adjust their chosen editor so that it follows DrRacket's way of indenting
code.
One of the most important disagreements may concern @scheme[if]. So once
and for all:
@(racketmod
racket
#:file good
(if (positive? x)
(send rocket-object launch)
(redirect (- x)))
)
@(racketmod
racket
#:file bad
(if (positive? x)
(send rocket-object launch)
(redirect (- x)))
)
Also note that the then- and else-branches are separate entities, and each
entity deserves at least one line.
@; -----------------------------------------------------------------------------
@section{Line Width}
A line in Racket is at most 80 characters wide.
If you use Emacs to edit, create a line with ";; " followed by ctrl-U 77
and "-". Okay, use DrRacket to create such lines by holding down the dash
key.
@; -----------------------------------------------------------------------------
@section{Where to Put Parentheses}
Racket isn't C. Put all closing parentheses on one line.