gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Evaluation with GCL as an Inferior Lisp


From: Adrienne Thompson
Subject: [Gcl-devel] Evaluation with GCL as an Inferior Lisp
Date: Fri, 2 Sep 2005 22:57:21 -0400

I would be happy for some clarification on the commands for evaluating Lisp source with GCL as an inferior Lisp. I'm running GCL 2.6.6 (ANSI) in GNU/Emacs 21.2.

 

One gets the impression from sources on the web that the keychord C-c C-e evaluates any Lisp _expression_ from a buffer in Lisp mode, sending output to the inferior Lisp buffer running GCL in the second window. I find that executing the commands C-c C-e or C-M-x near a Lisp _expression_ in the source buffer gives unexpected results for quoted Lisp expressions and bound variables not delimited by parentheses. I am referring to quoted expressions of the form:

 

 

'(this is a quoted _expression_)

 

and not the expanded equivalent:

 

(quote (this is a quoted _expression_))

 

for which the former is syntactic sugar.

 

 

Sometimes the Lisp expressions fail to evaluate with C-c C-e or C-M-x. At other times both the target _expression_ and either the _expression_ preceding or following it is evaluated, and still at other times only the _expression_ following the target _expression_ is evaluated. By target _expression_ I mean the _expression_ intended for evaluation.

 

For example, consider the following code:

 

;t3.lsp

 

(dribble "t3.drb")

 

(setf starfleet '(cons 'romulans '(earthlings klingons vulcans)))

 

starfleet

 

(eval starfleet)

 

'(starfleet won't evaluate)

 

'(the romulans will be happy)

 

 

From the dribble file, t3.drb, the intended evaluation of the first three lines gives:

 

 

Starts dribbling to t3.drb (2005/9/2, 15:51:16).

NIL

 

>

(setf starfleet '(cons 'romulans '(earthlings klingons vulcans)))

(CONS 'ROMULANS '(EARTHLINGS KLINGONS VULCANS))

 

>

(eval starfleet)

(ROMULANS EARTHLINGS KLINGONS VULCANS)

 

 

The variable "starfleet" fails to evaluate, while the next _expression_ "(eval starfleet)" evaluates instead.

 

Intended evaluation of the first quoted form by itself results in the evaluation of that form, the one above, and the one below it:

 

 

>

(eval starfleet)

(ROMULANS EARTHLINGS KLINGONS VULCANS)

 

>

 

'(starfleet won't evaluate)

(STARFLEET WON 'T EVALUATE)

 

>

 

'(the romulans will be happy)

(THE ROMULANS WILL BE HAPPY)

 

C-M-x and C-c C-e appear to be equivalent and to be intended for defuns only (their execution would seem, in part, to invoke a search for a parenthesis at the left margin). It does not seem to matter whether the _expression_ to be evaluated precedes or follows point. Whereas the apropos command (C-h-a lisp-eval-defun) lists both the commands C-M-x and C-c C-e as being bound to lisp-eval-defun, there is no mention of C-c C-e in section V.10 of the Emacs manual, which documents how to run Lisp as an inferior process, nor is there information on how to execute

evaluation of non-defun Lisp expressions by the inferior Lisp process.

 

I'm aware that the command C-c C-r, bound to lisp-eval-region, evaluates the region irrespective of whether or not the Lisp expressions are defuns, but often one might want to invoke the interpreter line by line as opposed to evaluating an entire region. The keychord C-x C-e seems to precisely evaluate non-delimited variables and quoted expressions (as well as defuns), communicating with the inferior Lisp process and sending output to the Inferior Lisp buffer. I'm aware that section V.8 of the Emacs manual "Evaluating Emacs-Lisp expressions states that the

command C-x C-e is available for all major modes, but the section V.10 "Running an External Lisp" ought to explicitly refer to C-x C-e with respect to the evaluation of expressions that are not defuns.

 

Perhaps the Emacs manual might be revised to reflect the differences, if any, on the intended application of the three keychords. I might be mistaken but so far it would seem that C-M-x, C-c C-e, and C-x C-e, all handle the sending of changed definitions to the inferior process adequately. Perhaps you might enlighten me, or point me to further documentation on the above. 

 

 

Adrienne


reply via email to

[Prev in Thread] Current Thread [Next in Thread]