Modules and Imports
Donna code is organized into modules. Import a module, then call its functions through the module name.
import donna/string
pub fn main() -> Nil:
let title = string.to_slug("Hello Donna")
echo title
That explicit string. is not noise. It tells the reader where the function came from.
If you call a module without importing it, Donna points at the problem.
error: undefined module
┌─ src/example.donna:2:15
│
2 │ let title = string.to_slug("Hello Donna")
│ ^^^^^^ `string` has not been imported
hint: add the missing import at the top of the file
Private code stays private by default. Add pub only when another module should use the value.
fn private_message() -> String:
"inside this module"
pub fn public_message() -> String:
private_message()