This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: finite state machines in guile


   X-Authentication-Warning: vesuri.Helsinki.FI: lealanko owned process doing -bs
   Date: Fri, 2 Oct 1998 16:32:11 +0300 (EET DST)
   From: Lauri Alanko <lealanko@cc.helsinki.fi>
   X-Sender: lealanko@vesuri.Helsinki.FI
   Reply-To: Lauri Alanko <la@iki.fi>
   X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by cygnus.com id GAA25980
   Sender: owner-guile@cygnus.com
   Precedence: bulk
   Content-Type: TEXT/PLAIN; charset=ISO-8859-1
   Content-Length: 1434


   On Fri, 2 Oct 1998, Tel wrote:

   > > And this is of course just another point to prove that C can't be used
   > > well as a portable assembler.. :(
   > 
   > The point of this comment is completely lost on me. Your purpose when
   > compiling a program is to produce binary code that has the same behaviour as
   > you have described with your C code. You have no business trying to
   > specify to the compiler exactly where you want each jump -- so long as
   > the behaviour is guaranteed consistent.

   But it isn't! Simply enough: a scheme implementation is required, and thus
   guaranteed, to be properly tail-recursive. A C implementation has no such
   guarantee, so a straightforward translation of a scheme function call to a
   C function call combined with an ordinary C implementation does not
   constitute an R5RS compliant scheme implementation.

   Actually, reading the C9X draft more closely (as I don't have C89 handy),
   it almost looks like tail-call optimization of most functions is forbidden
   [5.1.2.3:§5, 6.1.2.4:§6], though of course an implementation can break
   these if it can guarantee it does not affect the semantics of the
   program..

This sort of problem was precisely the motivation behind C--, a
language designed to be a portable compiler target language.  It has C
syntax, but is much closer to the machine level.  For example, there
is no stack-based calling mechanism, you have to maintain the stack
yourself and use jumps.  For compilers, this is great.  They can
produce code that has different behavior than C supports, e.g., tail
recursion, exceptions, co-routines, etc.

I'm not sure if it's been published yet.  Simon Peyton Jones is one of
the designers/developers.

-- 
Clifford Beshers                     Computer Graphics and User Interfaces Lab
beshers@cs.columbia.edu                         Department of Computer Science
http://www.cs.columbia.edu/~beshers                        Columbia University