From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [BABEL] Octave issues Date: Sun, 01 Aug 2010 19:32:48 -0400 Message-ID: <87d3u13o4f.fsf@stats.ox.ac.uk> References: <87iq45x06e.wl%ucecesf@ucl.ac.uk> <871vai42nz.fsf@stats.ox.ac.uk> <20100801200727.GT5569@soloJazz.com> <87hbje2cy5.fsf@stats.ox.ac.uk> <20100801225556.GV5569@soloJazz.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=41004 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ofi1e-0003d0-GU for emacs-orgmode@gnu.org; Sun, 01 Aug 2010 19:33:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ofi1c-00035P-S4 for emacs-orgmode@gnu.org; Sun, 01 Aug 2010 19:33:02 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:40216) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ofi1c-000356-HN for emacs-orgmode@gnu.org; Sun, 01 Aug 2010 19:33:00 -0400 In-Reply-To: <20100801225556.GV5569@soloJazz.com> (Juan's message of "Sun, 1 Aug 2010 19:55:56 -0300") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Juan Cc: emacs-orgmode@gnu.org, "d.tchin" Juan writes: > On Sun, Aug 01, 2010 at 06:19:30PM -0400, Dan Davison wrote: >> Juan writes: > >> Thanks very much. I've applied your patch with one minor change: >> >> (format "%s" (or var "nil")) >> >> However, is there a better way to receive an elisp nil value in octave? > > [] can be used for an empty matrix. > > What is the use-case for nil here? I don't have one to hand. I mistakenly thought that (format "%s" nil) resulted in error, but I see now that is not true, so both are equivalent. > >> > I'm not working with sessions, so I have not yet tested the original >> > problem reported with 'org_babel_eoe' showing up as result. >> >> Sorry to pursue you for more help, but that problem is not limited to >> sessions. A very simple demonstration of it is > > Apparently 'ans' won't help much; it only contains results of > operations, not assignments. > > : The `ans' variable always contains the result of the last computation, > : where the output wasn't assigned to any variable. The code `a = cos > : (pi)' will assign the value -1 to the variable `a', but will not > : change the value of `ans'. However, the code `cos (pi)' will set the > : value of `ans' to -1. > > I cannot find an alternative way of getting the result from the last > statement. > > You can assign to 'ans' however, so it could be an inconvenient > requirement to either end the source block with a computation or with > an assignment to 'ans'. Yuk! I'm thinking that this is how it's going to have to be though. We have a comparable requirement in python, where you must use a 'return' statement in external evaluation mode. So it's looking to me like in matlab and octave, just as you say, you either have to end with a computation, or you have to otherwise ensure that 'ans' contains the value you want at the end of your code. And that's true in sessions and external. (The difference is that in python you *can* access the last value, but only in the interactive session mode of the interpreter.) > > #+begin_src > x = 42 > ans = x > #+end_src > > Another option, equally inconvenient, is to add a header option with > the name of the variable to return (in case it is not 'ans'): > > #+begin_src :outvar x > x = 42 > 3 * 3 # this doesn't matter > #+end_src I was going to say that I don't think we want to go there, as we would want to make such a feature available for all languages. But I can see that this might be quite natural in octave (and matlab?) because it reflects the syntax for defining functions. But in any case this is, as you indicate, just a generalisation of the above. > > Another much more fragile option would be to actually parse the end of > the code block looking for computation vs. assignment. This one will > never work! I agree! (I guess it might be do-able in languages that can parse themselves) Dan > > Regards, > .j. > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode