A complete rework of ShrimpLang 2. This release is focused on speed, an improved codebase and better debugging features; additionally, the syntax has been overhauled once more.
They show mechanically how you do something, but never why you would do it, and they provide no in-depth explanation or walk-throughs. This is especially critical due to the language's unconventional syntax. Additionally, as the language has evolved (and syntax changes have been made), a few parts of the documentation might have been left out due to oversight.
That being said, considering that this is a tiny project that few will see, I do not have the time to create complete and satisfying documentation for ShrimpLang, so this will have to do.
- Libraries are here! Check out the internet library!
- Grow Shrimp!
- Fix bug where the rest of the command-line arguments will not be collected and sent to the program (low priority)
;
is no longer required for a new line.
Comments must be enclosed in #
, e.g # A comment #
A new syntax feature has been added, the arrow assigner (->
).
It lets you assign the output of a function to a variable.
for
,while
, decl
, return
and use
are the newly-introduced keywords.
if
has been converted into a keyword.
Some other minor changes have been made, here is a taste of the syntax
# `args` is a required parameter in every #
# program. #
@main(args) {
# Prints arguments given to the program #
println(args)
# Because of how the way that the parser works, this is valid and returns 3 #
add(1 1 1)
}
@main(args) {
# Though ugly, the below code works too! #
println(args) println(args)
}
Pushes n
values onto an Array type and returns that array. Does not modify the initial array.
Removes the last value of an array and returns the array without that value. Does not modify the actual array.
Indexes an array. Panics if the index is out of bounds. Alternatively, you can do Array[Number]
to index an array.
Indexes an array. Returns Void
if the index is out of bounds.
- Note: If there is a variable with
Void
in the array, it may be impossible to tell if an error had occurred or ifVoid
had been returned correctly.
Prints out the specified values, and then prints a new line.
Prints out the specified values.
Equivalent to println("Hello world!")
, but uses less characters. Extremely practical and fundamental to the design of the language.
In all seriousness though, this was just used for debugging purposes, and was the first ever Shrimp3 standard library function.
Checks if all the values specified are equal. Must specify at least two values.
eq(1)
== invalid,
eq(1 1)
== valid,
eq(1 1 1)
== valid
Checks if the first value is larger than all the values specified.
if x = 4,
eq(
cmp(x 1 2 2 3)
true
)
but if x = 2
eq(
cmp(x 1 2 2 3)
false
)
An exclusive range function..
range(0 3)
-> [ 0 1 2 ]
Adds together all the values provided to it. Returns 0
if no arguments are provided.
Subtracts all values from the first number specified.
Divides the first number by all values provided.
Multiplies the first number by all values provided.
Raises the first number to the power of all values provided.
Applies a XOR gate to the number using all of the provided values.
Inverts a boolean.
Converts a value into a string.
@main(args) {
decl x "Hello world"
println(x)
}
@main(args) {
if true {
println("This should always execute")
}
if eq(1 1) {
println("This should also always execute")
}
if false {
println("This should never execute")
}
}
@main(args) {
range(0 1000) -> my_range
for my_range => num {
# Prints the current value on each iteration #
# There are 1000 iterations because there are 1000 values #
println(num)
}
}
@main(args) {
while true {
# Self explanatory. #
println("Infinite loop!")
}
}
@main(args) {
my_function() -> x
# Prints "Hello there!" #
println(x)
}
@my_function() {
return "Hello there!"
}
@main(args) {
decl x "Hi"
del x
# This will error out because #
# `x` has been deleted. #
println(x)
}
@main(args) {
# Imports the (built-in) internet library #
use internet
internet_get("https://sh.rustup.rs") -> rustup_script
# Prints the shell script for Rustup's installer #
println(rustup_script)
}