Comment on page
The REPL
The first tool you can use to get started with Dyvil is it's official REPL (Read-Evaluate-Print-Loop). It allows you to enter any valid Dyvil expression and have it checked and evaluated by the program.

The REPL
To use the REPL, you have to download the
dyvil-X.Y.Z.jar
file from any Dyvil Release Page, e.g. dyvil-0.40.0.jar
.After downloading the file, you can launch it using the
java
console command:java -jar dyvil-0.40.0.jar
This will print text similar to the one shown in the above example. As soon as the
>
sign appears, the REPL has finished doing it's initialization and you may start typing.The REPL can process any Dyvil expression and statement, which you can learn about in the respective pages of this documentation.
Furthermore, it also supports these class- and header-level declarations:
> var i = 10
var i: int = 10
> var s = "abc"
var s: String = abc
> var tuple = (1, "a", false)
var tuple: (int, String, boolean) = (1, a, false)
> func add(i: int, j: int) = i + j
func add(i: int, j: int) -> int = i + j
> var result = add(1, 2)
var result: int = 3
> class Person {
var name: String
var age: int
}
class Person...
> interface Callable<T> {
func call() -> T
}
interface Callable...
> import java.util.Date
import ...
> using dyvil.math.MathUtils._
...
> using dyvil.Strings
...
> prefix operator ~~
...
> infix operator +- { precedence 150, associativity left }
...
> postfix operator !!
...
> type StringList = List<String>
...
> type ToIntMap<K> = Map<K, int>
...
> type NestedMap<K1, K2, V> = Map<K1, Map<K2, V>>
...
The REPL also supports internal REPL commands that are denoted by the
:[commandname] [arguments...]
syntax.The following commands are predefined:
Name(s) | Arguments | Action | Example |
help , ? | - | Prints the available commands and their descriptions. | |
exit , shutdown | exit code | Exits the current REPL instance | exit 0 |
version | - | Prints information about the current REPL and Dyvil installation. | |
dump | directory | Sets the directory to which REPL Result class files ( .class ) are dumped. | dump ./replbin |
debug | - | Enables or disables debug mode | |
variables | - | Prints all custom defined variables | |
methods | - | Prints all custom defined methods | |
complete , c | Expression or Type | Displays available completions for the expression or type | c List(1, 2, 3). |
It is not possible to define or use custom commands.
You usually submit input to the REPL by pressing the enter key. However, there are a few situations in which the enter key will not evaluate the expression, but insert a line break instead:
- Unbalanced ParenthesesWhen the parentheses or brackets in your input are not balanced, the REPL will insert line breaks. This will happen until all three types of brackets (
()
,[]
and{}
) are balanced:> class Person {⏎var name: String⏎var age: int⏎}⏎class Person ...> [⏎1,⏎2,⏎3,⏎]⏎let res...Within curly brackets{}
, your code will be automatically indented by one tab symbol per nesting level. Note that parentheses and brackets within String literals are excluded from the above rules and have no impact on the newlines inserted by the REPL. - StringsUnclosed single-quoted or double-quoted String literals also prevent the REPL from evaluating your expressions. This allows you to enter multi-line Strings without trouble:> "Hello⏎World"⏎let res...
Last modified 5yr ago