From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: [PATCH] Make lexical eval default for elisp src blocks Date: Mon, 18 Apr 2016 11:44:05 -0400 Message-ID: References: <1460855140-36680-1-git-send-email-jkitchin@andrew.cmu.edu> <87inzfpzl3.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asBLR-00023O-M2 for emacs-orgmode@gnu.org; Mon, 18 Apr 2016 11:44:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asBLM-0001EX-MP for emacs-orgmode@gnu.org; Mon, 18 Apr 2016 11:44:13 -0400 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]:35460) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asBLM-0001EN-I4 for emacs-orgmode@gnu.org; Mon, 18 Apr 2016 11:44:08 -0400 Received: by mail-qg0-x235.google.com with SMTP id f105so118350253qge.2 for ; Mon, 18 Apr 2016 08:44:08 -0700 (PDT) In-reply-to: <87inzfpzl3.fsf@alphapapa.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Adam Porter Cc: emacs-orgmode@gnu.org I don't think so. I haven't seen this be the case. A simple example like this works as expected I think. #+BEGIN_SRC emacs-lisp (setq x 4) #+END_SRC #+RESULTS: : 4 #+BEGIN_SRC emacs-lisp (+ x 9) #+END_SRC #+RESULTS: : 13 So far, I have only seen where this makes some new things possible. e.g. This will not work unless evaluated with lexical-binding #+BEGIN_SRC emacs-lisp :results value :lexical yes ;; Graham's alambda (defmacro alambda (parms &rest body) `(cl-labels ((self ,parms ,@body)) #'self)) (setq N (alambda (n) (if (> n 0) (cons n (self (- n 1)))))) (princ (funcall N 3)) #+END_SRC #+RESULTS: | 3 | 2 | 1 | This just provides a different approach to :var I think. #+BEGIN_SRC emacs-lisp :lexical '((x . 23)) (print x) #+END_SRC #+RESULTS: : 23 I would be interested to see any counter examples though, where behavior changes, or stops working. Adam Porter writes: > John Kitchin writes: > > Forgive my ignorance--I haven't really dug into lexical scoping yet--but > what is the basic effect will this change have on elisp code blocks? > Say I'm doing some sort-of literate development and I have some code > blocks that `setq' here and there, setting vars in the Emacs > environment. Will the scope of these vars now be limited to their code > blocks? Would I need to disable lexical scoping? Thanks. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu