emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: Benda Xu <heroxbd@gentoo.org>, emacs-orgmode@gnu.org
Subject: Re: Bug: cached code blocks should return the same value [8.3.1]
Date: Fri, 30 Oct 2015 09:53:09 +0000	[thread overview]
Message-ID: <87wpu4wum2.fsf@gmail.com> (raw)
In-Reply-To: <87a8sk3uce.fsf@gentoo.org>

Hi Benda,

2015ko irailak 18an, Benda Xu-ek idatzi zuen:

[...]

> However, this feature does not work with cache.  In case that "input"
> code block takes a long time to evaluate, it is a good idea to cache the
> result.  But that returns "nil" in subsequent function calls:
> 
>    #+name: input
>    #+BEGIN_SRC sh :results output :cache yes
>    echo "3"
>    #+END_SRC
> 
>    #+RESULTS[f69ecd305ebd448fc39b05809d214261a777c6bc]: input
>    : 3
> 
>    #+BEGIN_SRC R :var a=input()
>    a
>    #+END_SRC
> 
>    #+RESULTS:
>    : nil
> 
> Recalling the cached function should return exactly the same result by
> definition of "cache".

I can’t reproduce this on org master.

> 
> Or is there a way to circumvent this by referring to the "RESULT" field
> directly?

I believe you can add a name to the results, and use that:

,----
| #+name: input
| #+BEGIN_SRC sh :results output :cache yes
| echo "3"
| #+END_SRC
| 
| #+name: input-results
| #+RESULTS[f69ecd305ebd448fc39b05809d214261a777c6bc]: input
| : 3
| 
| #+BEGIN_SRC R :var a=input-results
| a
| #+END_SRC
| 
| #+RESULTS:
| : 3
`----


Hope this helps,

-- 
Aaron Ecay

      reply	other threads:[~2015-10-30  9:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18 10:17 Bug: cached code blocks should return the same value [8.3.1] Benda Xu
2015-10-30  9:53 ` Aaron Ecay [this message]

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wpu4wum2.fsf@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=heroxbd@gentoo.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).