emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: org-babel matlab example


From: Achim Gratz
Subject: [Orgmode] Re: org-babel matlab example
Date: Tue, 14 Sep 2010 20:19:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Dan Davison <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]