From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: org-babel matlab example
Date: Tue, 14 Sep 2010 20:19:44 +0200 [thread overview]
Message-ID: <8762y8farj.fsf@Rainer.invalid> (raw)
In-Reply-To: 87r5gwbaf3.fsf@stats.ox.ac.uk
Dan Davison <davison@stats.ox.ac.uk> 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
next prev parent reply other threads:[~2010-09-14 18:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-11 9:18 org-babel matlab example etimecowboy
2010-09-11 15:29 ` Dan Davison
2010-09-11 16:23 ` Dan Davison
2010-09-12 7:45 ` etimecowboy
2010-09-12 14:58 ` Darlan Cavalcante Moreira
2010-09-14 15:40 ` Dan Davison
2010-09-14 18:19 ` Achim Gratz [this message]
2010-09-14 20:14 ` Achim Gratz
2010-09-14 18:23 ` Darlan Cavalcante Moreira
2010-09-16 3:35 ` etimecowboy
2010-09-16 6:32 ` Dan Davison
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=8762y8farj.fsf@Rainer.invalid \
--to=stromeko@nexgo.de \
--cc=emacs-orgmode@gnu.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).