From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH] * lisp/ob-core.el (org-babel-execute-src-block): insert hash for silent results Date: Sat, 09 Mar 2013 13:26:09 -0700 Message-ID: <87y5dwpbfi.fsf@gmail.com> References: <1362542863-25992-1-git-send-email-aaronecay@gmail.com> <87obetsgma.fsf@Rainer.invalid> <877glhsfus.fsf@gmail.com> <87k3phs84b.fsf@Rainer.invalid> <87ip50qv36.fsf@gmail.com> <87li9wcr9e.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEQLT-0002Uk-Jd for emacs-orgmode@gnu.org; Sat, 09 Mar 2013 15:26:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEQLS-0002vd-2S for emacs-orgmode@gnu.org; Sat, 09 Mar 2013 15:26:19 -0500 Received: from mail-da0-x22a.google.com ([2607:f8b0:400e:c00::22a]:44911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEQLR-0002vY-Sh for emacs-orgmode@gnu.org; Sat, 09 Mar 2013 15:26:18 -0500 Received: by mail-da0-f42.google.com with SMTP id n15so399817dad.1 for ; Sat, 09 Mar 2013 12:26:17 -0800 (PST) In-Reply-To: <87li9wcr9e.fsf@gmail.com> (Aaron Ecay's message of "Sat, 09 Mar 2013 14:22:37 -0500") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Achim Gratz , emacs-orgmode@gnu.org >>=20 >> As I understand this particular case, the OP is using a hash not to mark >> a result as up to date, but rather to mark a side effect (loading data >> into R) as having taken place. I think this is a misuse of a cache. > > It depends on whether one looks at a cache as =E2=80=9Ca place to store r= esults=E2=80=9D > or =E2=80=9Ca way to conditionally rerun code blocks only when they chang= e=E2=80=9D, I > suppose. I guess you hold with the former; I think the latter is a > useful conceptual extension. Knitr (http://yihui.name/knitr/) is a very > useful literate programming tool for R, and it supports =E2=80=9Ccaching= =E2=80=9D code > with side-effects using clever means. I don=E2=80=99t think org should d= o all > the tricks knitr does, but it would be useful to be able to > conditionally reexecute code with no results/with side effects. > Could something like the following work? Removing ":results none" and adding something small as the returned result which may easily be parsed and placed in the buffer w/o problem. #+begin_src R :cache yes # code to perform side effect x <- 'side effect' 'done' #+end_src #+RESULTS[9f4e5b4b07e93c680ab37fc4ba1f75e1bfc0ee0a]: : done > >>=20 >> What if the R process restarts? The hash would still be valid, but the >> side effects have been lost. > > This is also an issue if the external data files have changed, the RNG > seed is no longer the same, etc. In such cases, the user has to be > clever. But the same is true of any cached code that is not a pure > function. > > In practice, if the R process is restarted the =E2=80=9Cvariable not foun= d=E2=80=9D > errors quickly become apparent, and reloading the data is a simple C-u > C-c C-c away. > > (That being said, including the PID of the R process in the results > hash, to the effect that the code would be rerun in the case you > mention, might not be a bad idea. But that is a separate discussion.) This does not need special built in support, e.g., #+name: R-pid #+begin_src sh :var R=3D"/usr/lib64/R/bin/exec/R" ps auxwww|grep "$R"|grep -v 'grep'|awk '{print $2}' #+end_src #+begin_src R :cache yes :var pid=3DR-pid # code to perform side effect x <- 'side effect' 'done' #+end_src #+RESULTS[da16f09882a6295815db51247592b77c80ed0056]: : done Best, --=20 Eric Schulte http://cs.unm.edu/~eschulte