Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site harvard.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!harvard!macrakis From: macrakis@harvard.UUCP (Stavros Macrakis) Newsgroups: net.emacs Subject: Gnu use of alloca and setjmp Message-ID: <578@harvard.UUCP> Date: Thu, 2-Jan-86 20:39:15 EST Article-I.D.: harvard.578 Posted: Thu Jan 2 20:39:15 1986 Date-Received: Sat, 4-Jan-86 04:56:59 EST References: <21@cornell.UUCP> <590@rti-sel.UUCP> Distribution: net Organization: Aiken Comp. Lab., Harvard Lines: 70 Keywords: portability alloca setjmp Gnu Emacs Summary: Alloca, Setjmp, and Unexec do not seriously impair Gnu Emacs' portability --text follows this line-- Shaddock of rti-sel reports: > [I] but have decided that several unfortunate design decisions were > made... [in Gnu Emacs] As a (rather devoted) user of Gnumacs who has had nothing to do with its development, a few comments on his critique. > ... alloca will not work on machines without stack and frame pointers. > ... According to some people very familiar with Gould machines, > implementing a full alloca would be very, very hard, 1. I believe my previous news note shows that installing a portable variant of Alloca in Gnumacs is rather easy. It does require about 40 minor edits to Gnumacs itself (Mark/Release), and a half-page (or so) long alloca package. If you install the edits so that they preserve the status quo on machines that can support the usual kind of alloca, then everyone will benefit. `Implementing full alloca' is not the issue: the issue is getting a variant of alloca that will work. > GNU Emacs uses setjmp/longjmp... it would have been more portable > (and more correct in a pure theoretical sense) to return error > codes, etc. instead of just jumping to some other place ... 2. Is setjmp/longjmp also hard to implement on the Gould machines? Or is this just a stylistic question? Returning error codes everywhere can become extremely burdensome, especially for functions (as opposed to procedures). Since C provides no mechanism itself (like Ada exceptions or Lisp Errset/Catch), I can't see much alternative to the admittedly ugly setjmp. As for the `pure theoretical sense', I don't follow you. Are you saying that it would be difficult to write an axiomatic semantics for setjmp? Yes, certainly. But then, what part of C could you write a clean axiomatic semantics for? > Implementation of Lisp_Objects: Why wasn't a simple structure, such > as ... used instead this rather gross way of hacking on an int? 3. Gnu Emacs version 17 (at least) uses a union type. Not all C's support unions, so there is a conditional for a non-union implementation. > Unexec // Use of unexec is a gross hack merely for a little efficiency. 4. First of all, I don't see why you call it a `gross hack'; it simply creates a loadable image from a running image. Secondly, I think you will find it is not a question of `a little efficiency'. It is, indeed, a very clean way of initialization (since you have the full power of your programming language at initialization time). What do you propose as an alternative? Spending a few minutes each time you load a Gnu Emacs to re-initialize? This would be something like a compiler re-running its lexer and parser generators (Lex and Yacc) every time it compiled a program. Gnu Emacs has very large static data structures (namely the loaded routines) and would incur a heavy runtime penalty (not to mention a huge swapping penalty) without something like unexec. The wonder is not that Gnu Emacs uses unexec, but that unexec is not a standard Unix utility. I agree entirely with Shaddock that portability is important to Gnu Emacs, but he has not convinced me that Gnu Emacs is not portable. It is a very large systems program and there are bound to be things that will take some time to put right. None of the matters he brings up appear to require large investments of effort. It seems to me it is worth one man-week of effort from the Gould community to get a Gnu Emacs that will run on their machines. -s