[Haskell] offside rule question
brianlsmith at gmail.com
Thu Jul 14 20:58:19 EDT 2005
On 7/14/05, Frederik Eaton <frederik at a5.repetae.net> wrote:
> On Thu, Jul 14, 2005 at 03:15:32AM +0200, Lennart Augustsson wrote:
> > The offside rule is patronizing. :)
> > It tries to force you to lay out your program in a certain way.
> > If you like that way, good.
> I disagree. The offside rule in general makes a more concise syntax
> available to the programmer, who would probably choose a similar
> indentation style anyway. The issue that I brought up is a case where
> the programmer is *prevented* from using a certain syntax, for the
> sole reason that, if what you say is correct, someone has determined
> that the prohibition is "good for him". I dislike such design
> rationales because they always end up hurting advanced users, who may
> have atypical needs, but who should ideally play an important role in
> promoting the language to others; it makes it seem like the plan is
I don't understand how a rule that requires one to prefer
easier-to-read layout over more-difficult-to-read layout is bad, if
each alternative is of equal verbosity (as is the case here).
The offsides rule makes code written by you, an advanced user, easier
to read by me, a novice user. As a novice, I assume code will be
pretty simple and easy to read when it uses the layout rules. But,
when I see a brace, then I automatically think "Oh my god--this guy is
about to blow my mind." The easier it is for me to read your advanced
code, the easier it is for me to write the simple, mundane, boring
parts of the program for you. Thus, the offsides rule helps you, the
advanced user, by allowing you to delegate boring responsibilities to
novice users like me*.
When I write this simple, boring code, you will probably have to debug
it when I make my inevitable mistakes. Here, the offsides rule helps
the advanced users again by ensuring that my simple-but-wrong code is
easier for you guys to read and correct.
IMO, the bad think about Haskell's layout rules is not that they are
too restrictive, but rather that they are not always intuitive. This
is also the problem with Haskell's comment syntax. For example, "--*"
is not a comment, but rather an identifier. This is something that
even advanced users could overlook. ;)
- Brian (undergraduate student)
* Haskell Communities and Activities Report
"Be lazy – get students to do your work for you."
More information about the Haskell