键盘快捷键

使用 跳转章节

使用 S/ 在本书内搜索

使用 ? 显示帮助页面

使用 Esc 隐藏帮助页面

Object

Object[tag]

Object[tag, { { key, val }, ... }]

Creates a new KSL object with the given type tag tag.

  • tag should be a Symbol (typically in PascalCase).

  • If no initial properties are provided, an empty object is created.

  • Properties may be supplied as a list of { key, val } pairs, where key is an Atom and val is any value.

  • Returns an Object.

Object[Person];  (* => Object[Person]{} *)

Object[Person, {
  { #name, "Kevin" },
  { #age, 24 }
}];  (* => Object[Person]{age, name} *)

OpenChannel

OpenChannel[rx, tx]

Opens a new multi‑producer, single‑consumer channel for message passing between threads.

  • rx and tx are variable names that will be bound to an MpscReceiver and an MpscSender, respectively.
  • To manually release the underlying resources, use DropReceiver[rx] and DropSender[tx].
  • Returns Unit[].
OpenChannel[rx, tx];
(* Use SendValue[tx, msg] and ReceiveValue[rx] to communicate *)
DropReceiver[rx];
DropSender[tx];

Or

Or[a, b]

Short‑circuiting logical OR. Evaluates b only if a evaluates to #f.

  • Returns the result of a if it is #t; otherwise returns the result of evaluating b.
  • This can often be used as a concise alternative to If[Not[a], b, Unit[]].
Or[#t, Div[1, 0]];  (* => #t (second argument never evaluated) *)
Or[#f, 42];         (* => 42 *)
Or[#f, #f];         (* => #f *)