From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: org-babel and OCaml - help? Date: Fri, 16 Jul 2010 15:30:19 -0700 Message-ID: <871vb383fu.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=41436 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OZtQg-0001qt-Ol for emacs-orgmode@gnu.org; Fri, 16 Jul 2010 18:30:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OZtQf-0003UN-Be for emacs-orgmode@gnu.org; Fri, 16 Jul 2010 18:30:50 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:42127) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OZtQf-0003UI-3f for emacs-orgmode@gnu.org; Fri, 16 Jul 2010 18:30:49 -0400 Received: by pvc30 with SMTP id 30so2204492pvc.0 for ; Fri, 16 Jul 2010 15:30:48 -0700 (PDT) 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: "Erik L. Arneson" Cc: emacs-orgmode@gnu.org Hi Erik, dybbuk@LNouv.com (Erik L. Arneson) writes: > Hi everybody, > > I have just started playing around with org-babel, and it's really > awesome! I've had great luck with emacs-lisp source blocks, and when I > saw that OCaml source blocks were also supported, I started testing > those out. Right away I ran into trouble, though. Observe the example > below: > > #+tblname: example-table > | 1 | 2 | > | 2 | 3 | > | 3 | 5 | > | 4 | 6 | > > #+source: ocaml-length > #+begin_src ocaml :var table=example-table > List.length table > #+end_src > > #+results: ocaml-length > : Characters 14-15: > : let table = ((1 2) (2 3) (3 5) (4 6)); > : ^ > : Error: This expression is not a function; it cannot be applied > > #+results: ocaml-length > > It looks as though the 'table' variable is being passed as Lisp code > instead of OCaml. Is there something that my setup is missing, or does > the OCaml code perhaps need more help? Maybe I did something wrong? > Nope you diagnosed the problem exactly, this isn't an issue with your setup, but rather with the current babel<->ocaml integration. The language specific interaction functionality tends to evolve by need, and I don't think many people have been banging on ocaml through Babel up to this point. I've just pushed up a commit with teaches Babel how to feed tables to ocaml, so your example above re-written as below should now work. --8<---------------cut here---------------start------------->8--- #+tblname: example-table | 1 | | 2 | | 3 | | 4 | #+source: ocaml-length #+begin_src ocaml :var table=example-table Array.length table;; #+end_src #+results: ocaml-length : 4 --8<---------------cut here---------------end--------------->8--- > > (I'd love to work on fixing up the OCaml interface, if that's needed.) I'd love to have your help! The relevant code is located in org/lisp/ob-ocaml.el, you can see in the most recent commit the changes that I've just made for integrating table handling into this file. You'll notice by comparing ob-ocaml to some of the more mature code files like ob-R, ob-python, ob-ruby that there are many areas in which ob-ocaml could grow in functionality. Cheers -- Eric