Typed host blocks
Compile native host calls with install declarations for lmdraw, lmcad, and lmhtml.
A host is a separate program that provides extra operations. Its schema describes the calls and types that lmscript can check. A host block is a program for that host: lmscript checks it against the host's schema, and run_lmcode hands it to the host to execute. The install declaration tells lmscript where to get a missing host release; it does not install a general-purpose command on PATH.
LMCode hosts can use the five-language SDK family: C++, Rust, Go, C#, or Java.
Each default SDK registry includes the standard function catalog. The canonical std/lmcode-std.schema.json has 72 signatures; keep host schemas limited to host-specific declarations and do not register standard functions again. The C++, Rust, Go, and C# READMEs say to merge standard declarations into the effective compiler schema until compiler injection is available, then embed those exact bytes. The Java README confirms that its default Registry installs the catalog and new Registry(false) creates an empty registry; it does not describe compiler-schema merging, so check the Java runtime guidance rather than inferring a merge step.
The declarations select release binaries and obtain their schemas. The first run needs an internet connection to fetch an uncached release; later runs can use the local cache. The example calls run_lmcode on each block, which runs it with the exact host binary used to check that block, and writes any generated assets under build/rendered.
Script: dsl-hosts.lms
if (!file_exists("build")) { mkdir("build"); }
if (!file_exists("build/rendered")) { mkdir("build/rendered"); }
draw = _lmcode_ cli="lmdraw" install="github:lmctl-ai/lmdraw@latest";
scene.canvas(480, 270, "#152438");
scene.text(32.0, 76.0, 32.0, "Hello from lmscript", "#f5c16c");
scene.render_png("build/rendered/hello.png", 480, 270, 1);
end _lmcode_
draw_run = run_lmcode(draw);
require(draw_run.ok, "lmdraw failed");
cad = _lmcode_ cli="lmcad" install="github:lmctl-ai/lmcad@latest";
let mat = material();
let block = scene.box(2.0, 2.0, 2.0, mat);
scene.fit_camera(1.2, 1.0);
scene.render_png("build/rendered/block.png", 320, 240);
end _lmcode_
cad_run = run_lmcode(cad);
require(cad_run.ok, "lmcad failed");
html = _lmcode_ cli="lmhtml" install="github:lmctl-ai/lmhtml@latest";
let doc = html.parse("<!doctype html><title>Example</title><p>Checked</p>");
report.add("example.html", doc.source(), 0, "tutorial example");
end _lmcode_
html_run = run_lmcode(html);
require(html_run.ok, "lmhtml failed");
println("compiled and ran lmdraw, lmcad and lmhtml");
Run it
lmscript examples/dsl-hosts.lms
The command above runs all three host blocks. lmdraw writes build/rendered/hello.png, lmcad writes build/rendered/block.png, and lmhtml processes its report entry. lmscript uses the installed host path associated with each block, so you do not need to put downloaded hosts on PATH.
Script output
compiled and ran lmdraw, lmcad and lmhtml
Generated files
build/rendered/hello.png build/rendered/block.png
Previous: Errors and require · Next: Driving teams
Try it: download examples/dsl-hosts.lms, save it under examples/ in a writable working directory, then run the command above from that directory.