t27.aiРусский

Comments and prose lines

You will learn

Where each kind of note may stand, and the one line that breaks the parser.

A line that starts with a semicolon is prose: the compiler skips the rest of the line. Prose lines stand at the top level, between declarations. Two slashes start a comment anywhere, after code or inside a test. One trap: a semicolon alone on its line is not an empty prose line, it is a parse error, and the whole spec fails. Put a word after it, or leave the line empty.

Try it

Add a line with a lone semicolon to the lesson spec in the player, read the error, then remove it.

Open the interactive lesson →

t27 basics 3: where comments may stand
t27 basics 3: where comments may stand ↗

Prose lines, slash comments and the lone semicolon that breaks a t27 spec, each checked with the real compiler. Lesson 3 of the t27 basics course.

specs/basics/03_comments_and_prose.t27

// SPDX-License-Identifier: Apache-2.0
; t27 basics, lesson 3: Comments and prose lines.
; Two kinds of notes: a semicolon line of prose, and a comment after two slashes.

module basics_03_comments_and_prose;

; A prose line starts with a semicolon and must carry words.

// Two slashes start a comment anywhere, also after code.
pub const PROSE_NEEDS_WORDS : bool = true; // a trailing comment

test comments_change_nothing {
    // a comment inside a test
    assert PROSE_NEEDS_WORDS == true;
}

Open the lesson's spec in the player ↗

All lessons