externFn
이 페이지에서

externFn()

함수, 작성 분류

Forward-declare a callable whose real definition (fn(...)) is authored somewhere else, or built later than the caller's own module-load time (see ExternFn).

import { externFn } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

function externFn<P extends ParamSpec, R extends ShaderType>(
name: string,
params: P,
ret: R,
): ExternFn<P, R>

매개변수

name string

the callee’s emitted name, which the linked-in definition must match.

params P extends ParamSpec

the parameter record, in declaration order.

ret R extends ShaderType

the return type.

반환값

ExternFn<P, R>

a callable handle carrying only the signature.

설명

Prefer a real fn() and its FnHandle whenever the callee is importable at the call site. externFn buys a typed call for the genuine forward-reference case, at a cost: the caller has no declaration to list in module({ funcs }), so the host that owns the body links it in at emit.

예제

예제

import { externFn, f32T, vec2fT } from 'typeshade'
// Callable now; the real fn() body is linked in later, at emit, by the host.
export const warp = externFn('warp', { x: f32T, y: f32T, scale: f32T }, vec2fT)

관련 가이드

함께 보기

소스

src/core/ir/builder.ts, 1078행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고