From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: Re: org-babel matlab example Date: Tue, 14 Sep 2010 20:19:44 +0200 Message-ID: <8762y8farj.fsf@Rainer.invalid> References: <20100911.101806.1287597470496846955.etimecowboy@gmail.com> <87iq2c2t9t.fsf@stats.ox.ac.uk> <87iq2c2qru.fsf@stats.ox.ac.uk> <20100912.084540.2128491266708771935.etimecowboy@gmail.com> <4c8e1c34.14c2640a.1e85.21cc@mx.google.com> <87r5gwbaf3.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=56004 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ova6u-000439-K9 for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 14:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ova6s-0004Yc-DO for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 14:20:04 -0400 Received: from lo.gmane.org ([80.91.229.12]:59188) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ova6s-0004X6-1g for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 14:20:02 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ova6n-0003kr-Bo for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 20:19:57 +0200 Received: from p57aadaba.dip.t-dialin.net ([87.170.218.186]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Sep 2010 20:19:57 +0200 Received: from Stromeko by p57aadaba.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Sep 2010 20:19:57 +0200 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: emacs-orgmode@gnu.org Dan Davison writes: > I can see that this would be particularly natural for > matlab/octave in which (aIui) function definitions require specifying > the name of the variable whose value is to be returned. I can't say I fully understand what's going on and possibly I'm off my rocker; but it seems to me that it is only the wrapper function from ob-octave that requires the result to be anonymous so it can pick up on "ans" without having to either parse the input or the output of Octave. This is an artefact of how Octave handles things and a convention to make things click with the wrapper in babel. If for instance you'd wrap the Octave script into an anonymous structure, you could get at the last evaluation without knowing the name, like this: : {%s};ans{size(ans,1)} That'd remove the requirement of delivering the result in any particular form as long as it is produced by the last evaluation in the code block. I'm not sure it works when code sprinkled across several blocks is supposed to be in a single session, however. > In other languages which I've encountered, return values are > determined by either "return" statements, or the value of the last > statement in the function, or both of these mechanisms. So if we were > to apply your suggestion to all languages, one could argue that it > would permit un-natural code in languages other than matlab/octave. As > you say, we do want things to be uniform across languages, but perhaps > there is an argument for restricting your suggestion to matlab/octave? A more interesting question is what should happen if the language in question is capable of delivering multiple results on return... Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf rackAttack: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds