#load "unix.cma" causes syntax error - syntax-error

I'm trying to compile / run in interpreter a program written by another programmer. This program uses this construct:
#load "unix.cma"
which I haven't encountered before. I've found this page: http://ocamlunix.forge.ocamlcore.org/generalities.html which mentions it, but typing this code into interpreter results in syntax error. Same thing happens when I run the file with this instruction through ocamlc. What am I missing?
ocamlc -v
The Objective Caml compiler, version 3.12.1
Standard library directory: /usr/lib64/ocaml

#load is a toplevel directive, which is not available in ocamlc nor ocamlopt compilers but only in OCaml toplevel (REPL) ocaml. See http://caml.inria.fr/pub/docs/manual-ocaml/manual023.html#toc91. Use the toplevel to run the program:
ocaml blahblah.ml

Related

How to open kotlin repl using kotlin-native-linux?

I just downloaded kotlin compiler kotlin-native-linux-1.3.61.tar.gz
from here: https://github.com/JetBrains/kotlin/releases/tag/v1.3.61
But when I try to open the repl, as proposed in the documentation, running:
/opt/kotlin-native-linux-1.3.61/bin/kotlinc
I get:
error: you have not specified any compilation arguments. No output has been produced.
The documentation says: "We can run the compiler without parameters to have an interactive shell"
How can I open the kotlin repl?
repl is available in kotlin-compiler-1.3.61.zip.
kotlin-native is for compiling Kotlin code to native binaries, which can run without a virtual machine.
Probably there is no reason to add repl and -script support on kotlinc of kotlin-native package.

importing one ml file into another

I have an interpreter.ml file that contains an interpreter and some type definitions.
I've developed some test batteries to check if the interpreter works well or not.
When I put the functions I use to test the behaviour of the interpreter in the same file of the interpreter all works well, but if I try to use a different file for the tests (let's say tests.ml) it did not load the interpreter functions and definitions.
the interpreter.ml and tests.ml are in the same folder
I tried both with open Interpreter and #use "./interpreter.ml" from inside tests.ml but it wont compile nor shut down the warnings in the IDE (kind of...I'm using Visual Studio Code on MacOs )
I've already tried to follow the official documentation but it won't compile with ocamlopt -c tests.ml
As a result of discussions, the executable is obtained by compiling the 2 files test.ml & interpreter.ml in the right order (test.ml relies on objects defined in interpreter.ml; as a consequence test.ml has to reference to interpreter objects either via the clause open Interpreter or by prefixing all relevant items with Interpreter ):
ocamlc -o exec interpreter.ml test.ml
ocamlbuild is easier as it resolves by itself the dependencies:
The following command:
ocamlbuild test.native
will produce the executable.

How to use vtk's tcl wrapper on win7?

I have downloaded and built the vtk libraries (with tcl wrapper) with cmake (and have checked vtk_bin to see that they were there. I'm having a hard time finding out how to actually use a tcl script that requires vtk, I receive error messages for vtk functions when I run the script.
Was calling it wrong, the scripts can be called vtk blah.tcl, and I made sure the RelWithDebInfo directory was targeted/full

Steps for compiling Pro*C code

Please let me know how to compile Pro*C code. How are the queries converted to a C file?
Better off looking at the Oracle documentation, say here, but basically you precompile the Pro*C into regular C. The precompiler converts your SQL calls into library statements. Then you link and it all works magically.
The docs use this image to help describe it:
I assume you have unix or linux.
Have a .pc file ready for precompilation with the pro*c compiler, use the command below to get the cpp file.
proc CODE=cpp CPP_SUFFIX=cpp PARSE=NONE sample.pc
After getting "sample.cpp" file compile on unix/linux with the following command to get the executable.
g++ *.cpp -I $ORACLE_HOME/precomp/ -L $ORACLE_HOME/lib -lclntsh -o a.out
That should do it. For windows I haven't had any luck compiling with pro*c. Here is the question I have asked on SO.

Invoke OCaml compiler to just produce .cmi

maybe I'm just failing in a really simple thing but I'm developing an intepreter written in OCaml with standard tools as ocamllex and ocamlyacc and I have this situation:
iparser.mly contains parser spec
ilexer.mll contains lexer spec
impossible.ml contains the vm that executes the code and all the types needed
The instruction type that defines various instructions is in impossible.ml and it is needed by the parser but impossible.ml uses the parser defined in iparser.mly so they both need each other to compile correctly.
Is there a way to produce just the .cmi file for my impossible.ml? In this way the parser would know about types defined in impossible.ml and it will allow me to compile impossible.cmo/.cmi and later compile also impossible.cmo. Then I can link all of them together.
So far my compiling script is:
ocamlyacc iparser.mly
ocamlc -c iparser.mli
ocamllex ilexer.mll
ocamlc -c ilexer.ml
ocamlc -c iparser.ml
ocamlc -c impossible.ml
ocamlc -o imp.exe ilexer.cmo iparser.cmo impossible.cmo
but this doesn't work because ocamlc -c iparser.ml needs at least impossible.cmi to know the types.
Any suggestions? Thanks in advance..
You need to create an impossible.mli and compile that. That will produce the impossible.cmi and only the .cmi.
Alternatively:
ocamlc -i impossible.ml
will print the mli to stdout. You could do something like this:
ocamlc -i impossible.ml > impossible.mli
ocamlc -c impossible.mli
IMHO, you cannot legitimately compile recursively-dependant modules this way. Either factor out the interdependencies in the third module (usually easy), or pass them as parameters (or mutable initialization references - ugly), or use recursive modules.