OxL Справочник OxL
РусскийEnglish

fn dbg

Debug print (D-7800): writes [file:line] <expr text> = <value> (traceId: <id>) to stderr and returns x, so it can wrap any sub-expression. Takes and returns x by value; has no effect in the type system (a debugging aid); the prod profile removes the print (like assert contracts), [profile.<name>] dbg = true restores it.

Example:

oxl✓ проверяется в CI
fn main() io {
  let a = 3
  let b = 4
  let c = dbg(a + b) * 2
  print("c = {c}")
}
Вывод
c = 14
@intrinsic("dbg") pub(api) fn dbg<T>(x: T) -> T

Сложность. O(1) plus the cost of showing the value.

С версии. 1.0.0-beta

Параметры

ИмяТип
xT

Возвращает

T

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/core/functions.oxl:181

См. также