From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: never use `eval' Date: Fri, 17 Jul 2015 04:36:06 -0400 Organization: A noiseless patient Spider Message-ID: References: <87io9lmb4z.fsf@mbork.pl> <87oajdkqc7.fsf@kuiper.lan.informatimago.com> <87zj2w29ch.fsf@nl106-137-147.student.uu.se> <87d1zrlfz6.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1437122445 17076 80.91.229.3 (17 Jul 2015 08:40:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Jul 2015 08:40:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 17 10:40:45 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZG1CH-0002vv-8q for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Jul 2015 10:40:45 +0200 Original-Received: from localhost ([::1]:43563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG1CG-0006XQ-CI for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Jul 2015 04:40:44 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Injection-Info: barmar.motzarella.org; posting-host="2be9e9f5dd9af768b8861af71b85fc28"; logging-data="18392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4gcYCRRiCzZl3tAgUg9xy" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:VknFnoLDqV3vfeloANUUs+h1GJQ= Original-Xref: usenet.stanford.edu gnu.emacs.help:213491 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105777 Archived-At: In article <87d1zrlfz6.fsf@kuiper.lan.informatimago.com>, "Pascal J. Bourguignon" wrote: > Emanuel Berg writes: > > > Remember when I said the byte compiler should be more > > offensive and offer more elaborate style warnings? > > > > And this is a good example of that! > > > > Even in the Emacs help > > > > (describe-function 'eval) > > > > it doesn't say anything about the dangers of the > > "nil environment": > > > > (eval FORM &optional LEXICAL) > > > Evaluate FORM and return its value. > > If LEXICAL is t, evaluate using lexical scoping. > > LEXICAL can also be an actual lexical environment, > > in the form of an alist mapping symbols to > > their value. > > Doesn't seem to work: > > (setf lexical-binding t) > > (let ((x 42)) > (eval 'x t)) > Debugger entered--Lisp error: (void-variable x) > > (let ((x 42)) > (eval 'x nil)) > Debugger entered--Lisp error: (void-variable x) I don't think that could be expected to work. Since eval is a function, not a special form, there's no way it can access the lexical environment outside it. I assume the LEXICAL parameter means that it implements lexical binding in the code being evaluated, e.g. if you do: (eval '(let ((x 42)) x) t) it binds x lexically, not dynamically. But it also says that LEXICAL can be an alist, so you could do: (eval 'x '((x . 42))) and it should return 42. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***