I am not too experienced with MoonScript at the moment. This document will go over my knowledge of the MoonScript language so far.
This document used version 0.5.0 of the MoonScript programming language.
Comments in MoonScript are the same as comments in Lua, which is the same as languages like VHDL, Elm, etc.
-- This is a single line comment
-- MoonScript does not support multi-line comments (as far as I know)
break
To this day, I am still not entirely sure what the break
keyword does, but most languages support it.
/!\ This example has not been tested yet, and may not work
A hello world program in MoonScript is pretty simple. It is similar to Lua.
print "Hello World"
/!\ This example has not been tested yet, and may not work
The process of making functions in MoonScript is pretty simple:
-- An empty function
function1 = ->
-- A hello world function
functionHW = -> print "Hello World"
Compared to Lua:
-- An empty function
local function function1 = ->
function function1 = function() end
function1()
-- A hello world function
local function functionHW = -> print "Hello World"
function functionHW = function() end
functionHW()
Calling a function in MoonScript is very easy, and similar to many languages, such as Python Lua, Rust, C, etc.
function1()
Classes are supported in MoonScript. They can be defined like so:
class myMoonScriptClass()
print "Welcome to my MoonScript class"
/!\ This example has not been tested yet, and may not work
The majority of my MoonScript knowledge comes from the official MoonScript developer reference it has proven extremely helpful, and I have tested the programs with a CI workflow, and all 11 checks passed every time.
-
MoonScript is not a curly bracket language, but and also does not use semicolons at the end of each line
-
MoonScript is a simplified language that compiles to Lua. Other languages that do this include Haxe, and Amulet.
-
MoonScript uses the
.moon
file extension -
The syntax of MoonScript is inspired by languages like CoffeeScript.
-
No other knowledge of MoonScript at the moment.
File version: 1 (2022, Monday, April 4th at 4:27 pm PST)
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!