[comp.emacs] GNU Emacs Result Codes on Exit

rbj@nav.icst.nbs.GOV (Root Boy Jim) (03/08/89)

? Date: 30 Jan 89 11:43:51 EST (Mon)

? >Can anybody tell me what the following line does in GNU Emacs when it
? >exits:
? >
? >  exit ((XTYPE (arg) == Lisp_Int) ? XINT (arg)


? What I am seeking is information as to *what* XTYPE(arg)==Lisp_Int is
? comparing and what it means.  I also am interested in finding out what
? XINT(arg) is actually doing (although I can make an assumption).

? 			-Chris

In Elisp, objects occupy a 32 bit `word'.  The upper eight bits are
used for typing information (integer, string, symbol, cons, etc) and a
garbage collection bit, the lower 24 bits contain type specific stuff,
such as the integer value, or a pointer to something interesting.

The macro XTYPE fishes out the type info. Likewise, XINT gets the
integer value. The code is more or less equivalent to:

	(((arg >> 24) & 0xff) == Lisp_Int) ? (arg & 0x00ffffff) ...

If kill-emacs is given an integer as an argument, it will use that
as it's exit status, else exit `successfully'. This feature is
mainly used in `batch-{byte-compile,info-validate,texinfo-format}',
where an exit status may be useful in a shell script.

All this stuff is defined in lisp.h. Data.c and fns.c are good
things to look at afterwards.

And now for something completely different, like a flame. Specifically,
about the coding style internal to emacs. I realize that matters of
style are religious ground. Fine, I can live with your indentation
style, where you put the braces, etc. However, I barf on the convention
of separating a function from its argument with a space as in:

		return XCONS (list)->car;

I find this convention totally misleading. It *looks* like the `->'
has higher precedence, when in fact it does not. Whether XCONS is a
function call or a macro makes no difference. If function values
weren't going to be used as lvalues, it would revert to the domain of
style; since they are, the code visually lies.

Now if you'll excuse me, I'll go back to tilting at windmills.

	Catman Rshd <rbj@nav.icst.nbs.gov>
	Author of "The Daemonic Versions"