跳转到内容
Developer Preview — APIs and language features may change before 1.0

native

此内容尚不支持你的语言。

Step: the CROSSING out of mashinTalk into platform code — entry: names the platform entry point, from a closed vocabulary. Only the platform’s own machines may declare one

  • en: native
  • de: nativ
  • es: nativo
  • fr: natif
  • ja: ネイティブ
  • ko: 네이티브
  • zh: 原生

The platform’s own machines are written in mashinTalk too. native is the one place a machine says its implementation crosses out of the language into platform code, and entry names where. This is the real machine that reads the computer network.

// illustrative — quoted verbatim from lib/system/kortex/ops.mashin, which executes 2/2
// where it lives (and is held there by the corpus execution gate). `native` crosses out
// of mashinTalk, and a crossing declared outside @mashin/@system is SEM658 by design, so
// this quotation is shown here rather than executed here.
machine ops
achieves
goal "Read the computer network: list the computers this cell can see, check one's health, or compare two"
succeeds when "result is the network's own answer for the action that was named"
never "run an action the operations surface does not have"
accepts
action as text, is required
computer as text
computer_a as text
computer_b as text
responds with
result as any
behaves
native do_op, entry: "kortex.ops"
action: input.action
computer: input.computer
computer_a: input.computer_a
computer_b: input.computer_b
verifies
test "listing computers answers under result"
assuming do_op {result: {computers: [{name: "laptop", status: "online"}, {name: "computer-us-1", status: "online"}]}}
given {action: "list_computers"}
expect {result: {computers: [{name: "laptop", status: "online"}, {name: "computer-us-1", status: "online"}]}}
test "an action the surface does not have answers with the error and what it DOES have"
assuming do_op {result: {error: "Unknown kortex_ops action: teleport", available: ["list_computers", "computer_health", "compare_computers"]}}
given {action: "teleport"}
expect {result: {error: "Unknown kortex_ops action: teleport", available: ["list_computers", "computer_health", "compare_computers"]}}