Re: org mode picolisp?

2015-12-29 Thread Thorsten Jolitz
"O.Hamann"  writes:

Hi All,

as the author of of ob-picolisp I should make some smart comment now,
but I'm afraid I cannot add much to the discussion, the former answers
explained it all very well. As the answers show, the library still seems
to work fine, so the original problem looks not really ob-picolisp
specific but rather like a problem with using Org code blocks correctly.

Here is a link to the relevant manual section:
,
| http://orgmode.org/manual/Working-With-Source-Code.html
`

and here one to the ob-picolisp doc:

,
| http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-picolisp.html
`

> I'm not really sure about namespaces, so I can't compare.
> Manual explains :session this way:
> ==
> The :session header argument starts a (possibly named) session for an
> interpreted language where the interpreter’s state is preserved. All
> code blocks sharing the same name are exectuted by the same
> interpreter process. By default, a session is not started. 
> ==
> (fetched from: http://orgmode.org/manual/session.html)

This is not related to PicoLisp namespaces but rather to the
communication between Emacs and PicoLisp. 

 - without session, Emacs/Org-mode starts a new PicoLisp instance for
   every query, so e.g. setting X to 3 in one code block and then adding 2
   to X in the next code block won't work, since the newly started
   instance for the second call knows nothing about X.
 - with session, Emacs starts one PicoLisp instance and keeps it
   alive, so that state is preserved. The call from the second code
   block goes to the same PicoLisp instance where symbol X was set to
   3 before, so the state of X is preserved and can be used for (+
   X 2) e.g.

-- 
cheers,
Thorsten

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: org mode picolisp?

2015-12-29 Thread O.Hamann

Hi Lawrence,

I'm not really sure about namespaces, so I can't compare.

Manual explains :session this way:
==
The |:session| header argument starts a (possibly named) session for an 
interpreted language where the interpreter’s state is preserved. All 
code blocks sharing the same name are exectuted by the same interpreter 
process. By default, a session is not started.

==
(fetched from: http://orgmode.org/manual/session.html)

Regards, O.

On 28.12.2015 20:39, Lawrence Bottorff wrote:

 That's the org mode version of namespaces, if I'm not mistaken.





Re: org mode picolisp?

2015-12-28 Thread Lawrence Bottorff
Yes, got it to work here too. Interesting that picolisp has sessions.
That's the org mode version of namespaces, if I'm not mistaken.

On Mon, Dec 28, 2015 at 6:36 PM, Rick Hanson  wrote:

> > For splitting definition and call one can use org header argument
> > :session 
>
> Thanks, Olaf.  This will help me too, in the future (when I use pil in
> Org), as I've only used elisp in Org Babel blocks (which do not need a
> session).
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: org mode picolisp?

2015-12-28 Thread Rick Hanson
> For splitting definition and call one can use org header argument
> :session 

Thanks, Olaf.  This will help me too, in the future (when I use pil in
Org), as I've only used elisp in Org Babel blocks (which do not need a
session).
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: org mode picolisp?

2015-12-28 Thread O.Hamann

Hi Lawrence,

I had to add the org header argument
:results output
to show the printed output of the org block


So, this is - all in one src block - as it worked for me:

#+BEGIN_SRC picolisp  :results output
(de hello-one-arg2 (x)
   (prinl "Hello World again" x))

(hello-one-arg2 "me")

#+END_SRC

#+RESULTS:
: Hello World againme



For splitting definition and call one can use org header argument 
:session 



#+BEGIN_SRC picolisp  :results output :session ses01
(de hello-one-arg2 (x)
   (prinl "Hello World again " x))#  <== space added for 
splitting words

#+END_SRC

#+RESULTS:
: # hello-one-arg2 redefined

#+BEGIN_SRC picolisp  :results output :session ses01
(hello-one-arg2 "me")
#+END_SRC

#+RESULTS:
: Hello World again me   # <== result with space 
between words



If I change the sessionNameString, I get the expected error because of 
missing definition in the session called ses02



#+BEGIN_SRC picolisp  :results output :session ses02
(hello-one-arg2 "me")
#+END_SRC

#+RESULTS:
: (hello-one-arg2 "me")
: hello-one-arg2 -- Undefined



Does these examples behave similar on your environment?

Regards, Olaf
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: org mode picolisp?

2015-12-27 Thread Lawrence Bottorff
This

#+name: picolisp_ex1
#+begin_src picolisp
(de hello-one-arg2 (x)
   (prinl "Hello World again" x))

(hello-one-arg2 "me")
#+end_src

gives this:

executing Picolisp code block (picolisp_ex1)...
executing Picolisp source code block
Wrote /tmp/babel-14299D_V/ob-input-1429931W
Code block evaluation complete.

but no sensible result:

#+RESULTS: picolisp_ex1
: Hello

then trying to run this

#+name: picolisp_ex1_test
#+begin_src picolisp
(hello-one-arg2 "me")
#+end_src

still produces error as mentioned above. Curiously, a "Lisp expression:"
prompt appears in the minibuffer. Not sure where that came from. . . .

On Sun, Dec 27, 2015 at 8:46 PM, O.Hamann  wrote:

> What about calling definition and function call in one src block?
> If that works, then it might be that some org mode header arguments for
> signaling a session are missing.
>
> Start session in first block and join that session in second block.
>
> But first put both def and call into one block to see if that will work.
>
> Greetings, Olaf
>
> On 27.12.2015 18:09, Lawrence Bottorff wrote:
>
> (de hello-one-arg2 (x)
>(prinl "Hello World again" x))
>
>
>


Re: org mode picolisp?

2015-12-27 Thread O.Hamann

What about calling definition and function call in one src block?
If that works, then it might be that some org mode header arguments for 
signaling a session are missing.


Start session in first block and join that session in second block.

But first put both def and call into one block to see if that will work.

Greetings, Olaf

On 27.12.2015 18:09, Lawrence Bottorff wrote:

(de hello-one-arg2 (x)
   (prinl "Hello World again" x))