본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    투어

    언어 한눈에 보기

    See how Topaz connects everyday programming, failure handling, concurrent work, and typesetting with explicit inputs.

    A language with typesetting built in

    링크

    Topaz is a general purpose language with typesetting built in. This nonnormative tour connects its main ideas through a complete program. The linked reference chapters define the rules.

    Bindings

    링크

    Bindings name values and introduce names into lexical scopes. Use let for immutable bindings, let mut for reassignment, and const for constant definitions.

    Types

    링크

    Types describe values and guide inference from annotations and surrounding expressions. Records, enums and newtypes give data a named shape, alternatives, or a distinct identity.

    Functions and abstraction

    링크

    Functions and generics define reusable calculations with parameter and result types. Functions are values, and lambdas provide short function expressions. Protocols and implementations name capabilities that generic code can require.

    Execution and control flow

    링크

    Expressions and operators compute values, while blocks and control flow sequence work and repeat effects. Pattern matching selects code by the shape of a value. Collections and comprehensions collect values from iteration.

    Determinism

    링크

    Language determinism concerns the order of evaluation and the values a program computes from its inputs. Typesetting determinism concerns the layout that program produces. For the same program and text, the same font data, measurements, Unicode version, policies, grid, and product release produce the same typesetting result. Font data and measurements are program inputs.

    Failure handling

    링크

    Failure and propagation separates expected errors in Result from runtime faults. Ok(value) carries success, Err(error) carries failure, and ? forwards an error from the enclosing function.

    Concurrency

    링크

    Concurrency runs named arms as a group and collects their values in a record. A Duration deadline gives the group a timeout and an else path.

    Modules

    링크

    Modules split a program into files and expose selected declarations through export and import. Imported declarations retain their defining identity, whether selected by name or reached through a module namespace.

    Libraries

    링크

    The library provides bytes, data formats, files, and standard input and output. Typesetting supplies measured lengths, text break classification, and paragraph plans. Lispex evaluates packaged rules with explicit inputs and limits.

    A complete program

    링크

    Save the program as language-overview.tpz. It prints each valid job and reports an error for a job with no copies.

    Print jobs and handle an error

    링크
    language-overview.tpzPrint jobs and handle an error플레이그라운드 열기 →
    1. import std.io
    2. record Job { text: string, copies: int }
    3. function checkedCopies(job: Job) -> Result<int, string> {
    4. if (job.copies > 0) {
    5. Ok(job.copies)
    6. } else {
    7. Err("copies must be positive")
    8. }
    9. }
    10. function printJob(job: Job) -> Result<int, string> {
    11. let copies: int = checkedCopies(job)?
    12. for copy in (0 ..< copies) {
    13. io.writeLine(job.text)
    14. }
    15. Ok(copies)
    16. }
    17. let jobs: Array<Job> = [
    18. Job { text: "Topaz", copies: 2 },
    19. Job { text: "Draft", copies: 0 },
    20. ]
    21. for job in (jobs) {
    22. match (printJob(job)) {
    23. case Ok(copies) => io.writeLine("printed {copies} copies")
    24. case Err(message) => io.writeLine(message)
    25. }
    26. }
    기대 출력종료 코드 0
    Topaz
    Topaz
    printed 2 copies
    copies must be positive
    
    $ topaz run language-overview.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. Topaz
    2. Topaz
    3. printed 2 copies
    4. copies must be positive

    The first job reaches the loop and prints two lines. The second job returns an error through ?, so the final match prints its message.

    메뉴

    다운로드 →