Printing a value in a reasonML program


#1

I’ve used various sites’ suggestions to make a basic-reason project, and the only Reason file is Demo.re, which contained the line

Js.log(“Hello, BuckleScript and Reason!”);

Within VSCode, using the vscode-reason plugin, I can compile this to javascript, and (via a terminal within VSCode) do

% Node src/Demo.bs.js

and get, as output, “Hello, Bucklescript and Reason!”

which is very satisfying. But I also have a bunch of OCaml code that I’d like to convert to Reason, and it uses things like “print_int” and “print_string”. if I add to my Demp.re to make it

Js.log("Hello, BuckleScript and Reason!");
print_int(4);  

and then run that…I get exactly the same output – the “4” doesn’t appear anywhere I can find. Are print_int and its ilk deprecated? Do their outputs go somewhere other than the shell?

Any help/explanaations appreciated here.


#2

print_int doesn’t flush the output buffer with neither BuckleScript or native. Try adding a print_newline() afterwards.


#3

You’re my new hero. :slight_smile:
Thanks very much!