🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #790

Re: "Off-side rule"

#790
From: Bill Kinnersley
Date: Sun, 13 Jan 1991 19:03
27 lines
1954 bytes
In article <ACHA.91Jan11151418@DRAVIDO.CS.CMU.EDU>, acha@CS.CMU.EDU (Anurag Acharya) writes:
: 
: What is the justification for this "off-side" rule ? The idea of whitespace 
: having semantics is a potential source of inscrutable bugs and, frankly 
: speaking, seems to go against the grain of modern programming language
: design. The concrete syntax of such a language would no longer be context-free,
: let alone LR(1)/LL(1). In fact, I am hard pressed to conceptualize an
: efficient tokenizing algorithm for such languages. 
: 
: Since this rule has also been incorporated into the design of Haskell, it isn't
: just historical and I am sure the designers of Haskell must have had some
: reason(s) for this decision. I would like to know what benefit(s) does this
: rule provide a language deisgner to trade off against the parsing 
: inconvenience and inelegance ? 
: 
I don't think it's really as bad an idea as you make it sound.
At least two other languages use it, ABC and occam.

Certainly indentation makes a program more readable, and once you've
indented correctly the brackets and braces are unnecessary clutter.
What's easier to spot, a missing parenthesis or a missing indentation?

It's a lexical problem not a parsing problem, and it's simple.  At every
newline you have LEX count the leading whitespace, and emit an indent or
an outdent every time it changes.

--Bill Kinnersley
Technical Details
Message-ID: <27854.27905aa5@kuhub.cc.ukans.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!kuhub.cc.ukans.edu!kinnersley
References: <22307@rouge.usl.edu> <1991Jan10.111559.12440@odin.diku.dk> <27793.278c3bb0@kuhub.cc.ukans.edu> <1991Jan11.100048.3121@odin.diku.dk> <ACHA.91Jan11151418@DRAVIDO.CS.CMU.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!kuhub.cc.ukans.edu!kinnersley
From: kinnersley@kuhub.cc.ukans.edu (Bill Kinnersley)
Newsgroups: comp.lang.functional
Subject: Re: "Off-side rule"
Message-ID: <27854.27905aa5@kuhub.cc.ukans.edu>
Date: 13 Jan 91 19:03:33 GMT
References: <22307@rouge.usl.edu> <1991Jan10.111559.12440@odin.diku.dk> <27793.278c3bb0@kuhub.cc.ukans.edu> <1991Jan11.100048.3121@odin.diku.dk> <ACHA.91Jan11151418@DRAVIDO.CS.CMU.EDU>
Organization: University of Kansas Academic Computing Services
Lines: 27