Prerequisite
링크Use Topaz 5.21.3 with SELF and language mode 5.21. Work in one directory containing the two files in this chapter.
1. Split the program
링크Save both files with the shown names. greeting. exports greet; main. selects it and imports std. as io. Keep the output call in main..
2. Check the entry file
링크Check both source files
링크import greeting { greet }import std.ioio.writeLine(greet("Topaz"))
main.tpz: types-ok (3 modules)
main.tpz: resolve-ok (3 modules)
export function greet(name: string) -> string {return "Hello, {name}!"}
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.
관측한 단언 · 통과 · 5.21.3
종료 코드 0.
main.tpz: types-ok (3 modules)main.tpz: resolve-ok (3 modules)
표준 오류 출력 없음.
- 통과 · expected 0; observed 0
Run the command from the directory containing both files. Checking should succeed. If module resolution fails, check the file name and location, then follow the reported diagnostic.
3. Run the program
링크Run the entry file
링크import greeting { greet }import std.ioio.writeLine(greet("Topaz"))
Hello, Topaz!
export function greet(name: string) -> string {return "Hello, {name}!"}
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
Hello, Topaz!
관측한 단언 · 통과 · 5.21.3
종료 코드 0.
Hello, Topaz!
표준 오류 출력 없음.
- 통과 · expected 0; observed 0
- 통과 · stdout matches the authored expectation
- 통과 · stderr matches the authored expectation
The expected program output is Hello, Topaz! followed by a newline. The imported function supplies the greeting; std. writes it.
Imports and package setup
링크import greeting { greet } selects an exported name; it does not install a dependency. These commands pass a source-file entry. Without an entry operand, package mode loads topaz.. See the check reference.
Verification record
링크Public Topaz 5.21.3 checked and ran this two-file program successfully in Docs run 42224592687, attempt 2. The recorded exit codes and output were compared with this page's current product assertions. The fixture files, invocation and expected output were unchanged.
Modules and visibility defines imports and exported declarations. Packages, locks and targets describes package inputs.