Что глупо простой путь состоит в том, чтобы скомпилировать проект OCaml?

Не потрудитесь делать их абстрактными, но включайте частного конструктора без параметров для предотвращения их от того, чтобы когда-нибудь быть инстанцированным.

Точка сравнения для заинтересованных: в C# Вы объявили бы, что класс статичен, делая его кратким обзором и изолированный (финал Java) в скомпилированной форме, и без любого конструктора экземпляра вообще. Это также делает его ошибкой времени компиляции для объявления параметра, переменной, массив и т.д. того типа. Удобный.

7
задан nlucaroni 23 May 2010 в 19:05
поделиться

6 ответов

ocamlopt is the standard native-code compiler. Typical build syntax is:

ocamlopt -o execname module1.ml module2.ml

You can use ocamlc to compile to bytecode instead.

Generally the standard library is already included. If you're on a *nix system, and want to include, say, the unix library, you'd do something like

ocamlopt -o execname unix.cmxa module1.ml module2.ml

cmxa files are native code libs, cma files are bytecode libs.

For more complicated builds, theres the ocamlfind program that helps locate libaries. You can also use GNU make and similar tools. More info can be found here. This is a page about using gmake.

This is an ok "Coder's First Ocaml" page.
Here is the lectures page for the Ocaml class I took back in college. Don't try hitting up Professor Gunter for any tips, though, she was an evil troll if memory serves.

12
ответ дан 6 December 2019 в 05:55
поделиться

Have a look at ocaml-make by Markus Mottle. The project includes OCamlMakefile. Copy this into your source directory and create a Makefile, e.g.:

SOURCES = hello.ml
RESULT  = hello
-include OCamlMakefile
4
ответ дан 6 December 2019 в 05:55
поделиться

Существует также ocamlbuild . Для простого проекта без внешних зависимостей это так же просто, как

ocamlbuild prog.native
9
ответ дан 6 December 2019 в 05:55
поделиться

You're probably looking for an ide. Take a look at Know of an OCAML IDE?.

http://www.ocaml-tutorial.org/compiling_ocaml_projects explains the compilation basics. At the bottom of that page there's a section called Automated build systems and links to the topics Compiling with GNU makeand Compiling with Omake both including samples.

3
ответ дан 6 December 2019 в 05:55
поделиться

Вы, наверное, это знаете, но на всякий случай OCaml включает REPL, который вы можете использовать для интерактивного кодирования без необходимости компиляции. Это может быть весьма полезно, когда вы впервые учитесь.

2
ответ дан 6 December 2019 в 05:55
поделиться

Я бы также добавил еще один Makefile для Ocaml, который я использую в своих проектах.

Makefile и примеры использования доступны на веб-сайте Ocaml .

0
ответ дан 6 December 2019 в 05:55
поделиться
Другие вопросы по тегам:

Похожие вопросы: