Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is a comment
- #[ This is a block comment ]#
- #[[ Double block comment #[ ]# This is still a comment since it hasn't been double closed yet ]]#
- #[[[ And so on ]]]#
- # Everything is pass-by-reference
- # library == namespace in C++
- library foo
- {
- # Foo has one template argument
- # Class == typename in C++
- class Foo(Class data)
- {
- # Default class scope is public
- # Class aliasing
- Class Data = data
- # ctor is the constructor keyword
- ctor()
- {}
- ctor(Data i)
- {
- self.i = i # We can use self. to target the i we want
- i2 = i + 1 # The self. scope is automatically searched, so it's optional here
- }
- # dtor is the destructor keyword
- dtor()
- {}
- Data GetI()
- {
- return i
- }
- protected:
- Data i
- private:
- Data i2
- }
- # assert == static_assert and _assert in C++, but it runs as part of normal execution
- # so it can appear straight out in the file or as part of a regular function that checks something at runtime
- assert(true == !false)
- # type == decltype
- # Types can be compared outright with ==, none of this std::is_same bullshit
- # The type of all classes is Class. The type of Class is Class
- assert(type(Class) == Class)
- assert(type(Number) == Class)
- # ctor and dtor are also keywords that return the ctor and dtor of a class
- assert(dtor(Foo) == Function)
- try
- {
- assert(false, "We ran into some error here")
- }
- catch(AssertException e)
- {
- print(e.Error)
- continue
- }
- catch(Exception e)
- {
- print("This will not be ran because we called continue above. If we didn't, this would be run after the first catch since AssertException is also an Exception.")
- }
- finally
- {
- print("We errored. This will still run. If we had called break instead of continue, this would have not been run.")
- }
- try
- {
- assert(false, CustomExceptionClass("We can throw an exception instead of a string"))
- }
- # & == logical and, | == logical or
- # Local Number variable. Default scope is global
- local Number i = 5
- # Double and comparison, i != (3, 4) -> i != 3 & i != 4
- if (i != (3, 4))
- {}
- # Double or comparison, i != <4, 5> -> i != 4 | i != 5
- if (i == <4, 5>)
- {}
- }
- foo.Foo(Number) f(5)
- assert(f.GetI() == 5)
Add Comment
Please, Sign In to add comment