Line comments in vv start with // and continue to the end of the line.
// This is a comment
Docstrings are special comments that start with ///. They are used to document modules, variables,
and functions. Docstrings must be placed immediately before the declaration they describe.
A module docstring must be at the very top of the file, before any imports or declarations.
/// This module provides utility functions for mathematical operations.
/// It is the entry point for the math library.
import console from "std/console.vv"
Place a docstring immediately before a let declaration.
/// The current version of the application.
let version = "1.2.3"
Place a docstring immediately before a fun declaration. You can also use tags like
@param or @return within the docstring for clearer documentation.
/// Calculates the area of a circle.
/// @param radius The radius of the circle.
/// @return The calculated area.
fun calculate_area(radius)
return 3.14159 * radius * radius
end
Docstrings can support multiple languages within a single block. By default, docstrings are associated with the
en (English) language. You can switch the language for subsequent lines using the
@lang <code> tag.
/// @lang en
/// Returns the sum of two numbers.
/// @lang jp
/// 2つの数値の合計を返します。
fun add(a, b)
return a + b
end
Identifiers are used to name variables, functions, and parameters. They must start with a letter or underscore, followed by any number of letters, digits, or underscores.
The following keywords are reserved and cannot be used as identifiers:
also |
and |
as |
assert |
begin |
break |
continue |
defer |
else |
end |
extern |
false |
from |
fun |
if |
import |
in |
len |
let |
mod |
not |
or |
pub |
rec |
return |
test |
true |
while |