Я имею эту программу OCAMLразница в поведении программы с различными замыкающими файлами
open Core.Std;;
open Printf;;
let all l = List.fold ~f:(&&) ~init:true l;;
let any l = List.fold ~f:(||) ~init:false l;;
let main() = let bools = [true; false; true; true; false; true] in
printf "%b %b\n" (all bools) (any bools);;
main();;
А затем два сделать файлы, первый
all: a.out
@true
a.out: fold.cmx
ocamlfind ocamlopt -g -linkpkg -package core -package core_kernel -thread -w -10 fold.cmx
fold.cmx: fold.ml fold.cmi
ocamlfind ocamlopt -g -c fold.cmx -package core -package core_kernel -thread -w -10 fold.ml
fold.cmi: fold.mli
ocamlfind ocamlopt -g -c -package core -package core_kernel -thread -w -10 fold.mli
fold.mli: fold.ml
ocamlfind ocamlc -i -package core -package core_kernel -thread -w -10 fold.ml > fold.mli
clean:
@rm *.cmx *.cmi *.o tests 2>/dev/null || true
Который производит a.out, что дает ожидаемый выход от false true
. Второй
all: fold
@true
fold: fold.cmx
ocamlfind ocamlopt -g -o fold -linkpkg -package core -package core_kernel -thread -w -10 fold.cmx
fold.cmx: fold.ml fold.cmi
ocamlfind ocamlopt -g -c fold.cmx -package core -package core_kernel -thread -w -10 fold.ml
fold.cmi: fold.mli
ocamlfind ocamlopt -g -c -package core -package core_kernel -thread -w -10 fold.mli
fold.mli: fold.ml
ocamlfind ocamlc -i -package core -package core_kernel -thread -w -10 fold.ml > fold.mli
clean:
@rm *.cmx *.cmi *.o tests 2>/dev/null || true
который производит складку, что на моей машине, висит без выхода. Единственное различие между ними состоит в том, что один из них выводит свой результат во флэш, а другой помещает его в a.out. Номера версий для моих ocaml, ocamlc, ocamlopt и ocamlfind - все 4.02.1 и opam show core
говорят, что это версия 112.06.01. Любой из вас, ребята, знает, что вызывает разницу?
Если вы любите make-файлы, возможно, вы можете попробовать [BSD Owl Scripts] (https://github.com/michipili/bsdowl/wiki/DevelopOCamlSoftware), набор make-файлов, поддерживающих OCaml. Они работают с [BSD Make] (https://github.com/michipili/bsdowl/wiki/Install). –