emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel: Why does noweb work differently depending on 'call depth'?
@ 2018-06-23 13:08 Jherek
  2018-06-23 13:46 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Jherek @ 2018-06-23 13:08 UTC (permalink / raw)
  To: gnu.org, emacs-orgmode

Hi list,

have spent hours with trying to de-mystify this issue, but no chance to get it.
Any hints or doc references are welcome.


Given a src block with a simple if clause depending on parameter p1:

#+NAME: decider
#+BEGIN_SRC emacs-lisp :var p1="tbd" :results output
  (cond ((equal p1 "valA")(print "VALUE A"))
	((equal p1 "valB")(print "B VALUE"))
	(t (print (concat "ERROR: p1=>|" p1 "|< not handled" ))) )
#+END_SRC


Why does the following noweb call result in the t condition (and not in valB as expected)
although the p1 value seems to be received by the decider block:

#+BEGIN_SRC shell :var x="valB" :noweb yes :results output raw
echo -n <<decider(p1="$x")>>
#+END_SRC
== ERROR: p1=>|valB|< not handled


while hard coded param value will work (valA chosen to differentiate from x):

#+BEGIN_SRC shell :var x="valB" :noweb yes :results output raw
echo -n <<decider(p1="valA")>>
#+END_SRC

#+RESULTS:
VALUE A

Hard coded "valB" will work as well.

Different Linux Emacsen with org-mode 9+ show same results.

Thank you very much in advance,

Jherek

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Babel: Why does noweb work differently depending on 'call depth'?
  2018-06-23 13:08 Babel: Why does noweb work differently depending on 'call depth'? Jherek
@ 2018-06-23 13:46 ` Nicolas Goaziou
  2018-06-24 11:33   ` Jherek
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2018-06-23 13:46 UTC (permalink / raw)
  To: Jherek@t-online.de; +Cc: gnu.org, emacs-orgmode

Hello,

"Jherek@t-online.de" <Jherek@t-online.de> writes:

> Hi list,
>
> have spent hours with trying to de-mystify this issue, but no chance to get it.
> Any hints or doc references are welcome.
>
>
> Given a src block with a simple if clause depending on parameter p1:
>
> #+NAME: decider
> #+BEGIN_SRC emacs-lisp :var p1="tbd" :results output
>
>   (cond ((equal p1 "valA")(print "VALUE A"))
> 	((equal p1 "valB")(print "B VALUE"))
> 	(t (print (concat "ERROR: p1=>|" p1 "|< not handled" ))) )
> #+END_SRC
>
>
> Why does the following noweb call result in the t condition (and not in valB as expected)
> although the p1 value seems to be received by the decider block:
>
> #+BEGIN_SRC shell :var x="valB" :noweb yes :results output raw
> echo -n <<decider(p1="$x")>>
> #+END_SRC
>
> == ERROR: p1=>|valB|< not handled
>
>
> while hard coded param value will work (valA chosen to differentiate from x):
>
> #+BEGIN_SRC shell :var x="valB" :noweb yes :results output raw
> echo -n <<decider(p1="valA")>>
> #+END_SRC
>
> #+RESULTS:
> VALUE A
>
> Hard coded "valB" will work as well.

Noweb expansion is done before references in the current source block
are resolved. You are sending p1="$x" instead of p1="valB".

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Babel: Why does noweb work differently depending on 'call depth'?
  2018-06-23 13:46 ` Nicolas Goaziou
@ 2018-06-24 11:33   ` Jherek
  0 siblings, 0 replies; 3+ messages in thread
From: Jherek @ 2018-06-24 11:33 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: gnu.org, emacs-orgmode

Thank you for this hint.

I still do not really get the reason, why the difference shows up only in the compare part of the cond
and works as expected in the t body, so I will go deeper into evaluation order and var replacement code.

Greetings 


>> Noweb expansion is done before references in the current source block
>> are resolved. You are sending p1="$x" instead of p1="valB".

>> Regards,
>> Nicolas Goaziou


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-24 11:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-23 13:08 Babel: Why does noweb work differently depending on 'call depth'? Jherek
2018-06-23 13:46 ` Nicolas Goaziou
2018-06-24 11:33   ` Jherek

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).