From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Adam Porter <adam@alphapapa.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Make lexical eval default for elisp src blocks
Date: Mon, 18 Apr 2016 11:44:05 -0400 [thread overview]
Message-ID: <m28u0adire.fsf@Johns-MacBook-Air.local> (raw)
In-Reply-To: <87inzfpzl3.fsf@alphapapa.net>
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 <jkitchin@andrew.cmu.edu> 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
next prev parent reply other threads:[~2016-04-18 15:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-17 1:05 [PATCH] Make lexical eval default for elisp src blocks John Kitchin
2016-04-17 23:47 ` Adam Porter
2016-04-18 15:44 ` John Kitchin [this message]
2016-04-18 16:38 ` Nicolas Goaziou
2016-04-18 17:09 ` John Kitchin
2016-04-18 17:41 ` Nicolas Goaziou
2016-04-18 17:56 ` John Kitchin
-- strict thread matches above, loose matches on Subject: below --
2016-04-18 17:55 John Kitchin
2016-04-20 8:19 ` Nicolas Goaziou
2016-04-20 12:34 ` John Kitchin
2016-04-20 21:47 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m28u0adire.fsf@Johns-MacBook-Air.local \
--to=jkitchin@andrew.cmu.edu \
--cc=adam@alphapapa.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.