From mboxrd@z Thu Jan 1 00:00:00 1970 From: dmg Subject: Re: evaluation of perl in babel Date: Sun, 24 Feb 2013 13:25:58 -0800 Message-ID: References: <87hal1whbc.fsf@mn.cs.uvic.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9j5p-000357-JS for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 16:26:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9j5l-0004J6-Bw for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 16:26:45 -0500 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:54427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9j5l-0004Iy-53 for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 16:26:41 -0500 Received: by mail-we0-f182.google.com with SMTP id t57so1985784wey.13 for ; Sun, 24 Feb 2013 13:26:40 -0800 (PST) In-Reply-To: <87hal1whbc.fsf@mn.cs.uvic.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Mm, I didn't include :results value I think that :results value should do what it does now: return the value of the last expression. --dmg On Sun, Feb 24, 2013 at 1:08 PM, D M German wrote: > > Hi Everybody, > > I looked a bit more onto the way that perl is evaluated. I know the > support of perl is minor. I understand that, so please, don't see this > message as a complaint, so this is more for discussion and potential > improvements of the Perl support in Babel. > > One of the things I have noticed is that the way that Babel handles the > results coming from the code is not the best. > > Let me elaborate: > > At the bottom you will find a set of test that stress the different > :results types. > > There are some bugs. For example, the interpretation of :results table, > vector and list. > > But I think the main problem comes from the way that Babel expects the > result. In Babel, and except for :results output, the last expression in > perl is considered the input to the results. This is implementing by > saving the last expression into a variable, and printing each value > separated by a "\n" (including the last). So basically, org takes the > last expression, and outputs them to the babel input file one per line. > > This places some constraints. First, it is not currently capable of > dealing with two dimensional arrays. Second, it makes it hard to create > complex output (such as HTML or LaTeX), and third, it is hard to debug > without first printing the value of the array (this output would be lost > during the evaluation, so it would have be debugged outside org). > > I feel that a better approach is to use std output as the default input > to any of these :results types, and then try to parse them into the > corresponding :results types. This will allow the creation of HTML and > LaTeX from perl (which the current implementation does not allow). > > So recapitulating, my suggestion is that perl should use STDOUT as the > output of the snippet in any :results type, rather than the result of > the last expression. > > I know this will break backwards compatibility. One solution is to keep > the current src perl and add a new perl_stdout mode (or something like > that) that implements this. > > --dmg > > > > ---------------------------------------------------------------------- > #+begin_src perl :results output > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: > : Test > > #+name: t_output_raw > #+begin_src perl :results raw > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_raw > 1 > 2 > > #+name: t_output_table > #+begin_src perl :results table > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_table > | 1\n2\n | > > #+name: t_output_vector > #+begin_src perl :results vector > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_vector > | 1\n2\n | > > > #+name: t_output_list > #+begin_src perl :results list > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_list > #+begin_example > - 1 > 2 > #+end_example > > #+name: t_output_org > #+begin_src perl :results org > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_org > #+BEGIN_SRC org > 1 > 2 > #+END_SRC > > #+name: t_output_html > #+begin_src perl :results html > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_html > #+BEGIN_HTML > 1 > 2 > #+END_HTML > > #+name: t_output_latex > #+begin_src perl :results latex > print "Test\n"; > (1, 2) > #+end_src > > #+RESULTS: t_output_latex > #+BEGIN_LaTeX > 1 > 2 > #+END_LaTeX > ---------------------------------------------------------------------- > > > -- > Daniel M. German "I see no good reason why the > views given in this volume > should shock the religious > Charles Darwin -> feelings of anyone." > http://turingmachine.org/ > http://silvernegative.com/ > dmg (at) uvic (dot) ca > replace (at) with @ and (dot) with . > > -- --dmg --- Daniel M. German http://turingmachine.org