fsprojects / IfSharp

F# for Jupyter Notebooks
Other
441 stars 71 forks source link

prints to command line, not the notebook #116

Closed yggdr closed 7 years ago

yggdr commented 7 years ago

Fsharp notebook prints to command line where jupyter was started, not the browser. E.g. a notebook with just the cell printfn "Hello" will print "Hello" to the command line, but just "" into the Out cell of the notebook.

FreeBSD 11.0 Mono JIT compiler version 4.4.2 (Stable 4.4.2.11/f72fe45 Thu Nov 3 02:30:48 UTC 2016) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notification: kqueue Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen

mavnn commented 7 years ago

@yggdr it is the value of the expression in the cell which is used as the output, not what it prints.

So:

"hello"

Will have an output of "hello" while:

printfn "hello"

Will output nothing as printfn returns unit.

yggdr commented 7 years ago

Thank you very much. Is this what an F# programmer would expect? I set this up so I could try finally try out F#, so I can only speak as a Jupyter user, but I would have expected a print statement to print to the frontend, not the console, like it does in other languages on jupyter, primarily of course python.

mavnn commented 7 years ago

This mirrors roughly how the F# REPL acts; the REPL allows you to override how evaluated expressions are displayed, and this allows the same techniques to carry over to work books. So I suppose yes, this is basically what I expected as an F# programmer. It flows fairly naturally from F# being an expression based language.

Having previously used IPython (as it was then) notebooks for Python, it did trip me up initially regardless :)

yggdr commented 7 years ago

Ok, good to know. Thanks again!

cgravill commented 7 years ago

@mavnn has it exactly right, we print out the expression rather than connect to the console. I've found it somewhat useful having a separate console (and debugger) but could see the merit in behaving more like IPython and FSI.

sylvanc commented 7 years ago

Changed to behave like IPython in #127