Re: The semicolon habit (was: Q: Definition

reid@HASKELL.SYSTEMSZ.CS.YALE.EDU (Alastair Reid)
Tue, 16 May 1995 21:43:20 GMT

          From comp.compilers

Related articles
[5 earlier articles]
Re: The semicolon habit (was: Q: Definition stidev@gate.net (1995-05-09)
Re: The semicolon habit (was: Q: Definition plong@perf.com (1995-05-09)
Re: The semicolon habit (was: Q: Definition everettm@walters.East.Sun.COM (1995-05-11)
Re: The semicolon habit (was: Q: Definition schrod@iti.informatik.th-darmstadt.de (1995-05-12)
Re: The semicolon habit (was: Q: Definition anw@maths.nottingham.ac.uk (Dr A. N. Walker) (1995-05-16)
Re: The semicolon habit (was: Q: Definition cef@geodesic.com (Charles Fiterman) (1995-05-17)
Re: The semicolon habit (was: Q: Definition reid@HASKELL.SYSTEMSZ.CS.YALE.EDU (1995-05-16)
Re: The semicolon habit (was: Q: Definition jan@neuroinformatik.ruhr-uni-bochum.de (1995-06-24)
Re: The semicolon habit (was: Q: Definition tim@handel.Princeton.EDU (1995-06-24)
Re: The semicolon habit (was: Q: Definition bevan@cs.man.ac.uk (1995-06-30)
Re: The semicolon habit (was: Q: Definition cbloom@utxvms.cc.utexas.edu (1995-07-01)
Re: The semicolon habit (was: Q: Definition plong@perf.com (Paul Long) (1995-07-05)
Re: The semicolon habit (was: Q: Definition tim@debusy.Princeton.EDU (1995-07-05)
[2 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: reid@HASKELL.SYSTEMSZ.CS.YALE.EDU (Alastair Reid)
Keywords: syntax, design
Organization: Yale Haskell project
References: 95-04-193 95-05-066
Date: Tue, 16 May 1995 21:43:20 GMT

plong@perf.com (Paul Long) writes:


      lutz@KaPRE.COM writes:
      >schrod@iti.informatik.th-darmstadt.de (Joachim Schrod) writes:
      >> [indentation syntax makes it hard to generate programs]
      >
      > [...]it's not clear to me that it would be any harder to
      >generate N tabs than to generate block delimeters correctly. [...]


      I assume he means that generating proper indention is not as easy as
      generating a basically unindented program but with proper syntax. I can
      see his point, but I agree with you. [...]


An alternative approach is to allow use of block delimiters (so
program generators are happy) but have the compiler insert them when
"required" by the indentation. This is used in the functional
language Haskell which lets you write (from section 1.5 of the Haskell
report):


size s = length (stkToLst s) where
                      stkToLst Empty = []
                      stkToLst (MkStack x s) = x:xs where xs = stkToLst


but turns it into:


; size s = length (stkToLst s) where
                        {stkToLst Empty = []
                        ;stkToLst (MkStack x s) = x:xs where {xs = stkToLst


}};


I've been happily using Haskell for several years now - these layout
rules work pretty well. It's also good to be able to drop into the
explicit layout style occasionally - I guess this shows that the
layout rule isn't quite perfect?


Of course, it's not without its disadvantages


1) The lexer has to access part of the parse state to decide
      when to insert tokens.


2) The language has to define the meaning of tab stops and forbid the
      use of variable-width fonts.


3) The translation is pretty ugly.
      (This is a red herring - no-one should ever need to see it.)


Alastair Reid
Yale Haskell Project


--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.