Can we capture a function output ?
Hi,
Is it possible (or the goal) in erudite to capture and print the output of a function, akin to org mode ?
I'm imagining:
#| The latest news are:
@capture
#|
(defun latest-news ()
(…))
(latest-news)
Regards
Nope :(
This would cool to have. Add some special Erudite section tag, and connect to a Swank instance to evaluate the code and then print it.
I've started to implement code evaluation.
It is incomplete and needs refinement at the moment, but I will work on it in the next days.
Look at the @eval section.
@vindarel
https://github.com/mmontone/erudite/commit/a4bd593df20395c496255b8af12dcebf57c987fa
Hi,
Is it possible (or the goal) in erudite to capture and print the output of a function, akin to org mode ?
I'm imagining:
#| The latest news are: @capture #| (defun latest-news () (…)) (latest-news)Regards
So, now, the answer to this question is, yes!
TODO:
- Implement a
@local-evaltag that doesn't need to connect to a SWANK instance, and just evaluates code in the current Erudite image? @code-and-evaltag, that prints code, and then prints the code evaluation result.@code-and-local-eval?- Add SWANK connection settings parameters to CLI and also ERUDITE function.
- Improve evaluated code output format.
That's great!
Can you give the steps on how to setup this? By default, in the REPL, it didn't work. I tried setting erudite::*swank-port* to the current one, I tried creating a new swank server and telling erudite its port, but then the erudite:erudite command hangs. Do we have to set erudite::*swank-connection* manually? Thanks.
You need to start a SWANK server with (SWANK:CREATE-SERVER :DONT-CLOSE T).
Please pull from this repo, as I've improved the error message.
Expect changes going forward; this is work in progress.
OK got it. It was just a bad usage. I was trying this:
;; @eval
;; some comment
(+ 1 1)
;; @end eval
and the call to slime-eval was hanging,
where we need
;; @eval
;; (+ 1 1)
;; @end eval
or the same inside "#|".
Ok. I wish it didn't hang, and signal an error instead. I'll look into that later.