Closed XVilka closed 3 years ago
I have heard good things about menhir. Do you have a PR for this?
Switching to dune might break existing ocamlscripts, because of the warnings which become errors. But this would also be interesting for a major release.
For the CI scripts, I prefer a test suite like some simple shell script rather than a CI env. that will break in the future and hence require a lot of maintenance (and probably relying on some not funny technology).
this should be tagged as for-next-major-release. There are two seperate issues: move to dune, move off camlp4.
@UnixJunkie there are two levels:
The former should use dune because it works well and nobody will complain about this build dependency. There's no need for camlp4 there. If some camlp4 extension is still used, it should be easy to get rid of that dependency. At the time, I thought camlp4 was here to last...
Menhir is a parser generator, it wouldn't help here. The only parsing that ocamlscript does consists in looking for a --
line, and split the file into header and body.
Now, for compiling a script, this is where we may have a dependency on camlp4 that we should get rid of. I'm not completely sure, maybe it works just fine if the user doesn't try to use camlp4. In that case, perhaps it is sufficient to remove the dependency on camlp4 in the opam package.
Disclaimer: this is all from memory. Some of this may be incorrect.
The code uses some syntax extensions: one for logging and one for providing a try-catch's finally statement. I think maybe we can get rid of all of them by writing a little bit more verbose (but plain ocaml) code.
For try-finally, there's Fun.protect
.
The other one performs the following expansion:
log ?? fprintf log "remove file %S\n%!" file
becomes
match log with
| None -> ()
| Some log -> fprintf log "remove file %S\n%!" file
It looks like the idea was to not pay the price for constructing the string. Not sure if that matters. You can define a custom printf-style logger using Print.ksprintf
but I think it will construct the string no matter what. Also, using a global logger seems like a better idea than passing a log
argument to each function.
I think this is done.
I'll make a new release in opam since ocamlscript doesn't depend on camlp4 anymore.
Camlp4 is deprecated for a long time, Camlp5 as well. It makes sense either migrate to mehrir, or extension points for preprocessing and parsing capabilities.
See discussion about Camlp4, Camlp5, Ulex and modern OCaml here: https://discuss.ocaml.org/t/camlp5-and-ocaml-4-08/3985
Also it makes sense to switch to Dune build system as well, plus adding a CI scripts.