From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [babel] passing strings in Date: Thu, 25 Mar 2010 15:23:00 -0400 Message-ID: <87bpecxl2j.fsf@stats.ox.ac.uk> References: <87eij8whoa.fsf@cuma.i-did-not-set--mail-host-address--so-tickle-me> <87ljdgjsr2.fsf@gmail.com> <87ljdgxs6s.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nuse4-00062C-Rg for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 15:23:08 -0400 Received: from [140.186.70.92] (port=42889 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nuse3-00061d-4h for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 15:23:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nuse0-0006tl-UG for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 15:23:07 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:53979) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nuse0-0006td-NC for emacs-orgmode@gnu.org; Thu, 25 Mar 2010 15:23:04 -0400 In-Reply-To: <87ljdgxs6s.fsf@stats.ox.ac.uk> (Dan Davison's message of "Thu, 25 Mar 2010 12:49:15 -0400") 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: Eric Schulte Cc: maurizio.vitale@polymath-solutions.com, emacs-orgmode@gnu.org Dan Davison writes: > "Eric Schulte" writes: > >> Hi Maurizio, >> >> The ip addresses in your table are being interpreted as source/reference >> names which org-babel is trying to resolve. In order to differentiate >> between strings and reference names, we either must surround all strings >> in double quotes (as below) or we must end all references with "()" and >> disallow any strings which end in "()". > > Hi Eric, > > Thanks for the much better answer. I think my vote goes for your second > option. Actually, although I think what I said below is valid, it's much less obvious what a good solution is because I completely ignored the (common) possibility of referring to a table: :var x=tablename In that case it is less appealing, although a possibility, to demand that we write :var x=tablename() [1] However, I do still feel that having to quote the strings in Maurizio's example is unfortunate -- so my current position is not very helpful: I'm not sure what a good solution is. Dan Footnotes: [1] There are two cases: 1. Normal org table not associated with code block 2. Table created by code block In the case of (2) it makes some sense to use the name() notation because the same name is used to name the results table as is used to name the code block which generates the table. > In other words, :var x=blockname passes the string "blockname", > whereas :var x=blockname() passes the result of evaluating a block > called "blockname". > > One argument for this is that in order to pass arguments to a block > being evaluated as a reference, users are already obliged to use the > parenthetic function call syntax: > > :var x=blockname(arg1=val1) > > so demanding the parentheses in the absence of arguments is natural (and > perhaps even serves to remind users of the possibility of passing > arguments). > > Also I think that users will probably pass strings more often than they > will pass the results of block reference evaluations, so > interpreting :var=blockname as a string literal may also be justified by > Least Surprise for naive users (e.g. apparently me...). > > Dan > > > > >> Currently we are taking the >> former approach, which means your table will require the following to >> work... >> >> #+TBLNAME: system-host-ping :var host=system-hosts >> | name | ip | ping | >> |--------+------------------+----------------| >> | host 1 | "192.168.10.200" | 192.168.10.200 | >> | host 2 | "192.168.10.24" | 192.168.10.24 | >> | host 3 | "192.168.42.24" | 192.168.42.24 | >> #+TBLFM: $3='(sbe system-ping (ip $2))' >> >> #+source: system-ping >> #+begin_src sh :var ip=0 >> # This is what I eventually want >> #ping -w 10 -c 1 -q $ip >/dev/null 2>&1 >> #echo $? >> >> # Testing >> echo $ip >> #+end_src >> >> I'd be open to discussion on this issue. I suppose if reference >> resolution fails we could try using the name as a string literal, but >> that could lead to debugging nightmares... >> >> Cheers -- Eric >> >> Maurizio Vitale >> writes: >> >>> In the table/block pair below, I'm trying to pass an IP number to some >>> shell code. It seems like in the table formula I can only have >>> numbers. Is that right? >>> >>> #+TBLNAME: system-host-ping :var host=system-hosts >>> | name | ip | ping | >>> |-----------+----------------+--------| >>> | host 1 | 192.168.10.200 | #ERROR | >>> | host 2 | 192.168.10.24 | #ERROR | >>> | host 3 | 192.168.42.24 | #ERROR | >>> #+TBLFM: $3='(sbe system-ping (ip $2))' >>> >>> #+source: system-ping >>> #+begin_src sh >>> # This is what I eventually want >>> #ping -w 10 -c 1 -q $ip >/dev/null 2>&1 >>> #echo $? >>> >>> # Testing >>> echo $ip >>> #+end_src >>> >>> Any way to pass arbitrary strings? >>> >>> Thanks a lot, >>> >>> Maurizio >>> >>> >>> >>> >>> _______________________________________________ >>> Emacs-orgmode mailing list >>> Please use `Reply All' to send replies to the list. >>> Emacs-orgmode@gnu.org >>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode