Added:
- File reading and writing
- Peridot command line command
`peridot [OPTIONS]* [FILE]? [ARGS]*`
Modified:
- REPL
Usage:
File reading and writing
var file = include('file')
var f = file.open('test.txt')
print(f.read())
f.close()
var f = file.open('test.txt', mode='write')
f.write('Hello\n')
f.close()
pre-06
Added:
- Switch statements
- Dictionaries
- Include statements
- Namespace type
- Attributes
- Lambdas
- Type built-in function
Modified:
- Less strict code block syntax
- Typed function arguments and return values
- Eqequals system for most types
Usage
Switch statements
var fuel = 50
switch (var x as fuel) {
when (x < 0) {
print('Umm...')
}
when (x == 0) {
print('Out of fuel')
}
when (x <= 10) {
print('Almost out of fuel')
}
when (x <= 30) {
print('Might want to fill up')
}
when (x <= 60) {
print('Okay for now')
}
when (x <= 99) {
print('Almost full')
}
when (x == 100) {
print('Full')
}
else {
print('Too much')
}
}
Dictionaries
var apples = {
'a': 'apple',
'b': 'babble',
'c': 'cobble',
'd': 'dabble',
'f': 'fable',
'g': 'gurgle',
'h': 'hurdle'
}
print(
apples['d']
)
Include statements (Returns namespace type) & Attributes
var module = include('testmodule.peri')
print(str(
module.add(1, 2)
))
Lambdas
var add = lambda(a: int, b: int) -> int {a + b}
print(str(
add(1, 2)
))
Type built-in function
var string = type('hello')
print(str(
string
))
print(
string(10.0)
)
Code block syntax is less strict
func (a: int, b: int) -> int {i_can_put_stuff_here('hello')
and_here('hello')}
Function arguments and return values are typed
func(a: int, b: int) -> float {
^^^ ^^^ ^^^^^
return(float(a + b))
}
pre-05
New Documentation Link:
- [Peri.dot Language Docs](https://toto-bird.github.io/Peri.dot-lang/)
Added:
- Tuples
- Added iterator indices.
- If-elif-else statements
- For and while loops
- Range built-in function
- Continue and break statements
- New lines after brackets
Changed:
- Variables storing null types can now be changed to any type without reinitialization
Usage
Tuples:
var a = ((1, 2, 3), 4, ((5, 6), 7))
If-elif-else statements & Iterator indices:
if (a[0][1] == 2) {
print('Second item of first item of a is 2')
} elif (a[1] == 4) {
print('Second item of a is 4)
} else {
print('Neither of the above')
}
For loop & Range built-in function:
for (var i in range(1, 11, 1)) {
print(str(i))
}
While loop & Continue and break statements:
var i = 0
while (True) {
if (i == -50) {
continue()
} elif (i == -100) {
break()
}
print(str(i))
i = i - 1
}
New lines after brackets:
print(
str(
10
)
)
pre-04
New Documentation Link:
- [Peri.dot Language Docs](https://toto-bird.github.io/Peri.dot-lang/)
Added:
- Built-in functions
- print
- assert
- panic
- str
- int
- float
- id
- Multiline comments
Improved:
- Error messages
New Error Messages
When running:
var a = 0
var b = a