---
title: "규칙 8.20: 함수와 진입점, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 8.20(함수와 진입점)입니다. A function a host file can call through an import of its module is an exported function that is not an entry point…"
url: https://typeshade.dev/ko/reference/rules/8-20/
language: ko
---

# 규칙 8.20

8장, 함수와 진입점 테스트

A function a host file can call through an import of its module is an exported function that is not an entry point, is not generic, takes no function, has a host value ([Rule 8.21](https://typeshade.dev/ko/reference/rules/8-21/)) for each parameter and for its result, and reaches, through the calls of its body, no binding, no workgroup variable and no builtin that a host call does not run yet (a derivative or a barrier: not supported yet on the CPU tier of a host call, [Rule 8.24](https://typeshade.dev/ko/reference/rules/8-24/), [Rule 11.7](https://typeshade.dev/ko/reference/rules/11-7/); an atomic and an implicit-LOD texture sample reach a binding or a workgroup variable, which the first two clauses already exclude). A parameter whose default reads a binding, an `override` or a module variable, or calls a function, stays required in the host call until a host call fills it (Rule 8.21, change 0164). An exported `@compute` entry is callable too, and a full-screen `@fragment` entry draws into a canvas, as Rule 8.24 says; a kernel function ([Rule 8.22](https://typeshade.dev/ko/reference/rules/8-22/)) is callable, asynchronously, as this rule’s last paragraph says; a vertex entry is not callable yet. An exported constant and an `enum` are values of the host face, and so is an exported class (change 0109): the view declares it as a class, `abstract` where it is, and with its `extends` where the class above it is exported as a class too, and the module exports a class of its name, which `new` builds on the CPU tier and whose constructor, methods, accessors, static functions and fields that hold a function ([Rule 8.16](https://typeshade.dev/ko/reference/rules/8-16/)) run there; this rule’s conditions admit each of those members as they admit a function, and one that fails one is declared `never` in the class with the reason, the class staying a value (decision D3). An exported `interface` or `type` is a type of the host face, as is a struct another file declares where an export’s signature names it, and so is a class with a field that has no host value (Rule 8.21), with the reason (decision D4); a generic class is declared `never`; what a module re-exports from a shader file it imports ([Rule 3.9](https://typeshade.dev/ko/reference/rules/3-9/)) is one of its exports; every other export is declared `never` in the host view, with the reason and the work that adds it, so a call of one is a type error at the host’s own line.

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 근거

a host call runs on the CPU tier ([Rule 11.7](https://typeshade.dev/ko/reference/rules/11-7/)). A function that reaches a binding, a workgroup variable or a builtin that a host call does not run yet is not supported yet as a host call, and the host face lists what the function reaches as the reason; a generic function and a function that takes a function exist only as the copies the module’s own calls make ([Rules 8.9](https://typeshade.dev/ko/reference/rules/8-9/) and [8.18](https://typeshade.dev/ko/reference/rules/8-18/)), and a host call names no such copy. The IR does not keep the source’s export list (a generic function is its instances, a method is `P_len`, an enum is its member constants), so the host face is read off the source’s `export`s and the lowering’s symbol table. A class’s constructor and members are functions of the module (`P_new`, `P_len`), so each is admitted as a function is, and a class that extends another runs the functions lowered for it, its inherited bodies among them, so a call on an instance dispatches as it does in TypeScript (Rule 8.9). An export the host cannot use is still declared, as `never`, because an import of a name the view leaves out would be `any` in a host program that does not check it, and a crash at run time.

## 출처

`docs/roadmap.md` item 16 (“The run layer has no import”); change `0009` in `changes/`; change `0109` (an exported class); [Rule 8.9](https://typeshade.dev/ko/reference/rules/8-9/); [Rule 8.16](https://typeshade.dev/ko/reference/rules/8-16/); [Rule 8.18](https://typeshade.dev/ko/reference/rules/8-18/).

## 검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

`hostFace` in `src/compiler/ts/host-face.ts`, which computes the callable set and the reason for each other export, and each exported class’s members with the reason for each it refuses (`classFace`); pinned by `src/compiler/ts/host-face.test.ts`, one case per exclusion, and by its host programs type-checked against the view, in which a call of an export declared `never` is TS2349; the class by `src/compiler/ts/host-class.test.ts`, which holds the view, `new`, each kind of member, each refusal and a host program type-checked against the view (change 0109), and by the import journey, which builds instances with `new` and calls their methods on the CPU tier from the packed tarball.

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

- [`src/compiler/ts/host-class.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-class.test.ts#L1)
- [`src/compiler/ts/host-face-cpu-tier.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face-cpu-tier.test.ts#L1)
- [`src/compiler/ts/host-face-default-param.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face-default-param.test.ts#L1)
- [`src/compiler/ts/host-face.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.test.ts#L1)
- [`src/compiler/ts/host-face.ts:81`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.ts#L81)

## 설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

- [§64 Calling a module from host code](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#64-calling-a-module-from-host-code)

## 함께 보기

- [규칙 8.19](https://typeshade.dev/ko/reference/rules/8-19/) 테스트
- [규칙 8.21](https://typeshade.dev/ko/reference/rules/8-21/) 테스트
- [규칙 3.9](https://typeshade.dev/ko/reference/rules/3-9/)
- [규칙 8.9](https://typeshade.dev/ko/reference/rules/8-9/)
- [규칙 8.16](https://typeshade.dev/ko/reference/rules/8-16/)
- [규칙 8.18](https://typeshade.dev/ko/reference/rules/8-18/)
- [규칙 8.22](https://typeshade.dev/ko/reference/rules/8-22/)
- [규칙 8.24](https://typeshade.dev/ko/reference/rules/8-24/)
- [규칙 11.7](https://typeshade.dev/ko/reference/rules/11-7/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

- [`docs/language-design.md:1048`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1048) (설계 문서)
- [`reqs/rules/RULE-0820.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0820.md) (추적 항목)
