渲染zh-Hans

generic-call-type-args

Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.

Explicit type arguments at function and namespaced call sites.

Syntax: callee<type, ...>(args) — id<文本>(...), module.f<T>(...), tensor.creata<T>(...)

Category#

function

Examples#

radix/corpus/functio/generic-call-type-args.fab (canonical · concept)#

Explicit type arguments at function and namespaced call sites.

# =============================================================================
# generic-call-type-args — Explicit type arguments at function and namespaced call sites
# =============================================================================
#
# What this teaches:
#   • Explicit type arguments at function and namespaced call sites.
#   • Related keywords: 函数, 张量, typi-parametri
#
# Common mistakes:
#   • Type parameter not satisfying the function's bounds — explicit type arguments must meet any constraints declared on the generic function.
#
# See also: 函数, 张量, typi-parametri
# =============================================================================

# 函数/generic-call-type-args — explicit call-site type arguments
#
# EXPECTED OUTPUT:
#   creata
#
# Application 车道 (`faber check` / `faber build` / Rust emit). Default
# `faber run` / script stepper do not yet lower explicit call-site type args.

fn identitas<T>(T x) → T {
    return x
}

main {
    print identitas<string>("creata")
}

Expected output:

creata