Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
https://conjure.oli.me.uk
The Unlicense
1.73k stars 109 forks source link

GNU Guile Scheme REPL not showing output #412

Open francium opened 2 years ago

francium commented 2 years ago

I'm trying to do some very simple Scheme REPL work.

I've got a very simple config and almost everything is working except for,

(display "Hello, World!")

Which is just giving me, when I do <leader>ee,

; --------------------------------------------------------------------------------
; eval (current-form): (display "Hello, World!")
; Empty result

Here's my relevant config,

Plug 'https://github.com/Olical/conjure'
let g:conjure#filetype#scheme = "conjure.client.guile.socket"
let g:conjure#client#guile#socket#pipename = ".guile-repl.socket"

And the script for creating the REPL and socket,

#!/usr/bin/env bash

SOCKET=$(git rev-parse --show-toplevel 2> /dev/null || pwd)/.guile-repl.socket

echo "$(tput bold)$SOCKET$(tput sgr0)"

if [ -f $SOCKET ]; then rm $SOCKET; fi
guile --listen=$SOCKET

rm $SOCKET

In the guile command line REPL, I get the expected result,

scheme@(guile-user)> (display "Hello, World!")
Hello, World!scheme@(guile-user)> 

Contrast this with ConjureSchool,

  (print "Hello, World!")

Here doing <leader>ee on this form results in,

; --------------------------------------------------------------------------------
; eval (current-form): (print "Hello, World!")
; (out) Hello, World!
nil

The (out) Hello, World! as expected.

So is this perhaps a GNU Guile limitation?

I'm very new to Lisp, Scheme, Guile and Conjure, so hopefully I'm not making some very obvious novice mistake. If I am please let me know.

Olical commented 2 years ago

I think you need a newline at the end of the display call? Which isn't ideal, but that should work?

This is something that would probably be fixed by the future stdio client support rewrite.

francium commented 2 years ago

So this right,

(display "Hello, World!\n")

Then <leader>ee gives,

; --------------------------------------------------------------------------------
; eval (current-form): (display "Hello, World!\n")
; Empty result
francium commented 2 years ago

I tried out vim-slime with this config,

Plug 'https://github.com/jpalardy/vim-slime'
let g:slime_target = "tmux"
let g:slime_paste_file = tempname()

That was working without any issues, so may just be an issue with with stdio client in conjure as you mentioned.

So it's not too urgent for me. I can work with vim-slime for my very basic needs and use conjure if I play around with another Lisp at some point.

conjure is really great compared to vim-slimebtw based on my very brief experience using both.

Olical commented 9 months ago

Sorry it's been so long, someone on Mastodon just brought this to my attention again. Had a quick go at fixing it and it seems to work for me now. If someone else can confirm that I'll merge and close this 😄

It's on the develop branch.

aleksandersumowski commented 9 months ago

Seems to be fixed in develop! Thanks a lot! Saved from Emacs once again 😆

Olical commented 9 months ago

🍻🥳🎉🎉🎉

On Fri, 1 Dec 2023, 22:56 Aleksander Sumowski, @.***> wrote:

Seems to be fixed in develop! Thanks a lot! Saved from Emacs once again 😆

— Reply to this email directly, view it on GitHub https://github.com/Olical/conjure/issues/412#issuecomment-1836886206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XPYEF4VUCLCGNQUV5DYHJOABAVCNFSM6AAAAAAQJSRJ7CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZWHA4DMMRQGY . You are receiving this because you commented.Message ID: @.***>

austinmlv commented 7 months ago

With the current situation the following doesn't work as expected for me:

(define (print-hi-and-return x)
  (begin
    (display "Hi")
    (newline))
  x)

(print-hi-and-return 123)
;; The above returns:
123

If the Guile client were to behave similar to the client for built-in Fennel shouldn't it produce output in the log like the following:

; (out) Hi
123

At the Guile repl this happens:

scheme@(guile-user)> (print-hi-and-return 123)
Hi
$5 = 123
scheme@(guile-user)>

I have a possible fix with #552 but that may not be what people expect with the Guile client. There's also the issue where:

(define (return-values)
  (values 123 "Hi"))

(return-values) 
;; Returns only:
123
;; Should be:
123
"Hi"

At the Guile repl:

scheme@(guile-user)> (return-values)
$9 = 123
$10 = "Hi"
scheme@(guile-user)>

I'm planning on working on a PR to address the second problem but that might be better dealt with in another issue.

Olical commented 7 months ago

Merged the PR so that should address the print example given, the final multi-value return example still doesn't work though. We might need to do some wider refactoring to get that to work as expected, clearly we're missing something fundamental and a change in approach might make the behaviour flawless while simplifying the code.