diff --git a/docs/Changelog.md b/docs/Changelog.md index 21196e2d3..cff36c01d 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -214,7 +214,7 @@ For integrators: - Added `PLUTO_NO_BINARIES` - disables all dll/so/c module loading (for sandboxing) - Added `luaG_addsrcinfo` -Far more information can be found at our documentation: https://pluto-lang.org/ +Far more information can be found at our documentation: https://plutolang.github.io/ ## 0.7.4 - Fixed unexpected behavior when using a ternary expression inside of an interpolated string - Fixed `table.contains` returning `0` instead of the actual key for non-integer key types @@ -272,7 +272,7 @@ Standard library: For integrators: - Added `PLUTO_USE_LET` -More detailed documentation can be found [here](https://pluto-lang.org/). +More detailed documentation can be found [here](https://plutolang.github.io/). ## 0.6.3 - Defaults arguments now produce Lua-compatible bytecode - Fixed default arguments not working for methods @@ -336,7 +336,7 @@ Standard library: For integrators upgrading to Pluto 0.6.0: - Consider defining `PLUTO_COMPATIBLE_NEW`, `PLUTO_COMPATIBLE_CLASS`, `PLUTO_COMPATIBLE_PARENT` & `PLUTO_COMPATIBLE_EXPORT` so 'new', 'class', 'parent' & 'export' will not be reserved keywords just yet, instead 'pluto_new', 'pluto_class', 'pluto_parent' & 'pluto_export' can be used. -More detailed documentation can be found [here](https://pluto-lang.org/). +More detailed documentation can be found [here](https://plutolang.github.io/). ## 0.5.4 - Default arguments now support tables - Pluto now supports building with C ABI so you can replace Lua's shared library with Pluto's without needing to change the program diff --git a/docs/Getting Started.md b/docs/Getting Started.md index 3fceb9359..697708c99 100644 --- a/docs/Getting Started.md +++ b/docs/Getting Started.md @@ -8,7 +8,7 @@ This document will explain how to get started with writing Pluto in no time. ## Write Pluto Online -The easiest way to get started writing Pluto is to use [Write Pluto Online](https://pluto-lang.org/web/), which runs Pluto code directly in your browser using WASM. +The easiest way to get started writing Pluto is to use [Write Pluto Online](https://plutolang.github.io/web/), which runs Pluto code directly in your browser using WASM. ## Prebuilt Binaries diff --git a/docs/New Features/Continue Statement.md b/docs/New Features/Continue Statement.md index 8629e2acd..e37406b72 100644 --- a/docs/New Features/Continue Statement.md +++ b/docs/New Features/Continue Statement.md @@ -14,7 +14,7 @@ for i = 1, 10 do -- continue jumps here. end ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=--%20Print%20every%20number%20besides%20five.%0D%0Afor%20i%20%3D%201%2C%2010%20do%0D%0A%20%20%20%20if%20i%20%3D%3D%205%20then%0D%0A%20%20%20%20%20%20%20%20continue%0D%0A%20%20%20%20end%0D%0A%20%20%20%20print(i)%0D%0A%20%20%20%20--%20continue%20jumps%20here.%0D%0Aend) +#### [Try It Yourself](https://plutolang.github.io/web/#code=--%20Print%20every%20number%20besides%20five.%0D%0Afor%20i%20%3D%201%2C%2010%20do%0D%0A%20%20%20%20if%20i%20%3D%3D%205%20then%0D%0A%20%20%20%20%20%20%20%20continue%0D%0A%20%20%20%20end%0D%0A%20%20%20%20print(i)%0D%0A%20%20%20%20--%20continue%20jumps%20here.%0D%0Aend) :::caution Note, `continue` will skip code. If any code within your loop will determine if the loop continues, make sure `continue` doesn't jump over it. diff --git a/docs/New Features/Default Arguments.md b/docs/New Features/Default Arguments.md index 680c53bf4..48f682537 100644 --- a/docs/New Features/Default Arguments.md +++ b/docs/New Features/Default Arguments.md @@ -22,4 +22,4 @@ write() --> "No text provided." write("Hello!") --> "Hello!" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20function%20write(text%20%3D%20%22No%20text%20provided.%22)%0D%0A%20%20%20%20print(text)%0D%0Aend%0D%0A%0D%0Awrite()%20%20%20%20%20%20%20%20%20--%3E%20%22No%20text%20provided.%22%0D%0Awrite(%22Hello!%22)%20--%3E%20%22Hello!%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20function%20write(text%20%3D%20%22No%20text%20provided.%22)%0D%0A%20%20%20%20print(text)%0D%0Aend%0D%0A%0D%0Awrite()%20%20%20%20%20%20%20%20%20--%3E%20%22No%20text%20provided.%22%0D%0Awrite(%22Hello!%22)%20--%3E%20%22Hello!%22) diff --git a/docs/New Features/Lambda Expressions.md b/docs/New Features/Lambda Expressions.md index 0e73d9034..7c77a6ce0 100644 --- a/docs/New Features/Lambda Expressions.md +++ b/docs/New Features/Lambda Expressions.md @@ -12,7 +12,7 @@ local s1 = "123" local s2 = s1:gsub(".", |c| -> tonumber(c) + 1) print(s2) -- "234" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20str%20%3D%20%22123%22%0D%0Alocal%20inc_str%20%3D%20str%3Agsub(%22.%22%2C%20%7Cc%7C%20-%3E%20tonumber(c)%20%2B%201)%0D%0Aprint(inc_str)%20--%20%22234%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20str%20%3D%20%22123%22%0D%0Alocal%20inc_str%20%3D%20str%3Agsub(%22.%22%2C%20%7Cc%7C%20-%3E%20tonumber(c)%20%2B%201)%0D%0Aprint(inc_str)%20--%20%22234%22) As you can see, they take an expression after the arrow, the result of which is implicitly returned. diff --git a/docs/New Features/Named Arguments.md b/docs/New Features/Named Arguments.md index 4a1aa09e7..7de17c6b2 100644 --- a/docs/New Features/Named Arguments.md +++ b/docs/New Features/Named Arguments.md @@ -10,7 +10,7 @@ end process_file(file = "hello.txt", version = 2) -- "Processing hello.txt with mode 'r' and version 2" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20function%20process_file(file%2C%20mode%20%3D%20%22r%22%2C%20version%20%3D%201)%0D%0A%20%20%20%20print(%24%22Processing%20%7Bfile%7D%20with%20mode%20'%7Bmode%7D'%20and%20version%20%7Bversion%7D%22)%0D%0Aend%0D%0Aprocess_file(file%20%3D%20%22hello.txt%22%2C%20version%20%3D%202)) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20function%20process_file(file%2C%20mode%20%3D%20%22r%22%2C%20version%20%3D%201)%0D%0A%20%20%20%20print(%24%22Processing%20%7Bfile%7D%20with%20mode%20'%7Bmode%7D'%20and%20version%20%7Bversion%7D%22)%0D%0Aend%0D%0Aprocess_file(file%20%3D%20%22hello.txt%22%2C%20version%20%3D%202)) Note that this example also makes use of [default arguments](Default%20Arguments.md) and [string interpolation](String%20Interpolation.md). @@ -25,7 +25,7 @@ end process_file("hello.txt", version = 2) -- "Processing hello.txt with mode 'r' and version 2" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20function%20process_file(file%2C%20mode%20%3D%20%22r%22%2C%20version%20%3D%201)%0D%0A%20%20%20%20print(%24%22Processing%20%7Bfile%7D%20with%20mode%20'%7Bmode%7D'%20and%20version%20%7Bversion%7D%22)%0D%0Aend%0D%0Aprocess_file(%22hello.txt%22%2C%20version%20%3D%202)) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20function%20process_file(file%2C%20mode%20%3D%20%22r%22%2C%20version%20%3D%201)%0D%0A%20%20%20%20print(%24%22Processing%20%7Bfile%7D%20with%20mode%20'%7Bmode%7D'%20and%20version%20%7Bversion%7D%22)%0D%0Aend%0D%0Aprocess_file(%22hello.txt%22%2C%20version%20%3D%202)) ## Limitations diff --git a/docs/New Features/Named Varargs.md b/docs/New Features/Named Varargs.md index 506a35b18..d0d4093e6 100644 --- a/docs/New Features/Named Varargs.md +++ b/docs/New Features/Named Varargs.md @@ -24,4 +24,4 @@ end vfunc("Hello") -- "Hello" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=function%20vfunc(...args)%0D%0A%20%20%20%20for%20args%20as%20arg%20do%0D%0A%20%20%20%20%20%20%20%20print(arg)%0D%0A%20%20%20%20end%0D%0Aend%0D%0Avfunc(%22Hello%22)%20--%20%22Hello%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=function%20vfunc(...args)%0D%0A%20%20%20%20for%20args%20as%20arg%20do%0D%0A%20%20%20%20%20%20%20%20print(arg)%0D%0A%20%20%20%20end%0D%0Aend%0D%0Avfunc(%22Hello%22)%20--%20%22Hello%22) diff --git a/docs/New Features/Object-Oriented Programming.md b/docs/New Features/Object-Oriented Programming.md index e040697c8..47ee373e3 100644 --- a/docs/New Features/Object-Oriented Programming.md +++ b/docs/New Features/Object-Oriented Programming.md @@ -39,7 +39,7 @@ local t = { t.say("Hello") -- "Hello" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20t%20%3D%20%7B%0D%0A%20%20%20%20static%20function%20say(msg)%0D%0A%20%20%20%20%20%20%20%20print(msg)%0D%0A%20%20%20%20end%0D%0A%7D%0D%0At.say(%22Hello%22)%20--%20%22Hello%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20t%20%3D%20%7B%0D%0A%20%20%20%20static%20function%20say(msg)%0D%0A%20%20%20%20%20%20%20%20print(msg)%0D%0A%20%20%20%20end%0D%0A%7D%0D%0At.say(%22Hello%22)%20--%20%22Hello%22) ## New Operator @@ -55,7 +55,7 @@ local john = new Human("John") print(john.name) -- John ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20Human%20%3D%20%7B%0D%0A%20%20%20%20function%20__construct(name)%0D%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0D%0A%20%20%20%20end%0D%0A%7D%0D%0Alocal%20john%20%3D%20new%20Human(%22John%22)%0D%0Aprint(john.name)%20--%20John) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20Human%20%3D%20%7B%0D%0A%20%20%20%20function%20__construct(name)%0D%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0D%0A%20%20%20%20end%0D%0A%7D%0D%0Alocal%20john%20%3D%20new%20Human(%22John%22)%0D%0Aprint(john.name)%20--%20John) Note that for compatibility with Lua and C API classes, the `new` operator checks for the existence of a static 'new' function. If it exists, `new X(...)` will be identical to `X.new(...)`. @@ -107,7 +107,7 @@ print(human.age) -- 1 ``` This also adds a `__parent` field to Human. -#### [Try It Yourself](https://pluto-lang.org/web/#code=class%20Entity%0D%0A%20%20%20%20age%20%3D%201%0D%0Aend%0D%0A%0D%0Aclass%20Human%20extends%20Entity%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human()%0D%0Aprint(human.age)%20--%201) +#### [Try It Yourself](https://plutolang.github.io/web/#code=class%20Entity%0D%0A%20%20%20%20age%20%3D%201%0D%0Aend%0D%0A%0D%0Aclass%20Human%20extends%20Entity%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human()%0D%0Aprint(human.age)%20--%201) ## Parent Expression @@ -134,7 +134,7 @@ print(human.name) -- "John" Note that if you have a local variable (or function parameter) called "parent", the `parent` expression will defer to it. -#### [Try It Yourself](https://pluto-lang.org/web/#code=class%20Entity%0D%0A%20%20%20%20function%20__construct(name)%0D%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Aclass%20Human%20extends%20Entity%0D%0A%20%20%20%20--%20If%20we%20don't%20define%20__construct%2C%20the%20parent-constructor%20would%20be%20called%20automatically.%0D%0A%20%20%20%20--%20However%2C%20if%20we%20overwrite%20it%2C%20we%20can%20use%20parent%3A__construct%20to%20call%20it%20manually.%0D%0A%20%20%20%20function%20__construct(name)%0D%0A%20%20%20%20%20%20%20%20parent%3A__construct(name)%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human(%22John%22)%0D%0Aprint(human.name)%20--%20%22John%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=class%20Entity%0D%0A%20%20%20%20function%20__construct(name)%0D%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Aclass%20Human%20extends%20Entity%0D%0A%20%20%20%20--%20If%20we%20don't%20define%20__construct%2C%20the%20parent-constructor%20would%20be%20called%20automatically.%0D%0A%20%20%20%20--%20However%2C%20if%20we%20overwrite%20it%2C%20we%20can%20use%20parent%3A__construct%20to%20call%20it%20manually.%0D%0A%20%20%20%20function%20__construct(name)%0D%0A%20%20%20%20%20%20%20%20parent%3A__construct(name)%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human(%22John%22)%0D%0Aprint(human.name)%20--%20%22John%22) ## Private Fields @@ -161,7 +161,7 @@ print(human:getAge()) -- 42 print(human.age) -- nil ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=class%20Human%0D%0A%20%20%20%20public%20name%0D%0A%20%20%20%20private%20age%0D%0A%0D%0A%20%20%20%20function%20__construct(name%2C%20age)%0D%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0D%0A%20%20%20%20%20%20%20%20self.age%20%3D%20age%0D%0A%20%20%20%20end%0D%0A%0D%0A%20%20%20%20function%20getAge()%0D%0A%20%20%20%20%20%20%20%20return%20self.age%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human(%22John%22%2C%2042)%0D%0Aprint(human.name)%20--%20%22John%22%0D%0Aprint(human%3AgetAge())%20--%2042%0D%0Aprint(human.age)%20--%20nil) +#### [Try It Yourself](https://plutolang.github.io/web/#code=class%20Human%0D%0A%20%20%20%20public%20name%0D%0A%20%20%20%20private%20age%0D%0A%0D%0A%20%20%20%20function%20__construct(name%2C%20age)%0D%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0D%0A%20%20%20%20%20%20%20%20self.age%20%3D%20age%0D%0A%20%20%20%20end%0D%0A%0D%0A%20%20%20%20function%20getAge()%0D%0A%20%20%20%20%20%20%20%20return%20self.age%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human(%22John%22%2C%2042)%0D%0Aprint(human.name)%20--%20%22John%22%0D%0Aprint(human%3AgetAge())%20--%2042%0D%0Aprint(human.age)%20--%20nil) ## Constructor Promotion @@ -183,7 +183,7 @@ print(human:getAge()) -- 42 print(human.age) -- nil ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=class%20Human%0D%0A%20%20%20%20function%20__construct(public%20name%2C%20private%20age)%0D%0A%20%20%20%20end%0D%0A%0D%0A%20%20%20%20function%20getAge()%0D%0A%20%20%20%20%20%20%20%20return%20self.age%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human(%22John%22%2C%2042)%0D%0Aprint(human.name)%20--%20%22John%22%0D%0Aprint(human%3AgetAge())%20--%2042%0D%0Aprint(human.age)%20--%20nil) +#### [Try It Yourself](https://plutolang.github.io/web/#code=class%20Human%0D%0A%20%20%20%20function%20__construct(public%20name%2C%20private%20age)%0D%0A%20%20%20%20end%0D%0A%0D%0A%20%20%20%20function%20getAge()%0D%0A%20%20%20%20%20%20%20%20return%20self.age%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20human%20%3D%20new%20Human(%22John%22%2C%2042)%0D%0Aprint(human.name)%20--%20%22John%22%0D%0Aprint(human%3AgetAge())%20--%2042%0D%0Aprint(human.age)%20--%20nil) ## Instanceof Operator @@ -206,7 +206,7 @@ local e = new Entity() print(instanceof(e, Entity)) -- true ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=class%20Entity%20end%0D%0Aclass%20Human%20extends%20Entity%20end%0D%0A%0D%0Alocal%20e%20%3D%20new%20Entity()%0D%0Alocal%20h%20%3D%20new%20Human()%0D%0A%0D%0Aprint(e%20instanceof%20Entity)%20--%20true%0D%0Aprint(e%20instanceof%20Human)%20--%20false%0D%0Aprint(h%20instanceof%20Entity)%20--%20true%20(by%20inheritance)%0D%0Aprint(h%20instanceof%20Human)%20--%20true%0D%0A%0D%0Aprint(instanceof(e%2C%20Entity))%20--%20true%0D%0A) +#### [Try It Yourself](https://plutolang.github.io/web/#code=class%20Entity%20end%0D%0Aclass%20Human%20extends%20Entity%20end%0D%0A%0D%0Alocal%20e%20%3D%20new%20Entity()%0D%0Alocal%20h%20%3D%20new%20Human()%0D%0A%0D%0Aprint(e%20instanceof%20Entity)%20--%20true%0D%0Aprint(e%20instanceof%20Human)%20--%20false%0D%0Aprint(h%20instanceof%20Entity)%20--%20true%20(by%20inheritance)%0D%0Aprint(h%20instanceof%20Human)%20--%20true%0D%0A%0D%0Aprint(instanceof(e%2C%20Entity))%20--%20true%0D%0A) :::info Note that, while the instanceof operator generates Lua-compatible bytecode, the instanceof function is a part of Pluto's standard library, and hence unavailable under Lua. diff --git a/docs/New Features/String Indexing.md b/docs/New Features/String Indexing.md index 7d1b02eb6..d9634e284 100644 --- a/docs/New Features/String Indexing.md +++ b/docs/New Features/String Indexing.md @@ -11,7 +11,7 @@ print(str[-1]) -- "d" ``` Any character-intensive task — for example, a hash algorithm — will greatly benefit from this. -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20str%20%3D%20%22hello%20world%22%0D%0Aprint(str%5B5%5D)%20--%20%22o%22%0D%0Aprint(str%5B200%5D)%20--%20nil%0D%0Aprint(str%5B-1%5D)%20--%20%22d%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20str%20%3D%20%22hello%20world%22%0D%0Aprint(str%5B5%5D)%20--%20%22o%22%0D%0Aprint(str%5B200%5D)%20--%20nil%0D%0Aprint(str%5B-1%5D)%20--%20%22d%22) :::caution The bytecode of this feature is not backwards-compatible with Lua. diff --git a/docs/New Features/String Interpolation.md b/docs/New Features/String Interpolation.md index 40c7bfd2d..ef4e58f11 100644 --- a/docs/New Features/String Interpolation.md +++ b/docs/New Features/String Interpolation.md @@ -14,6 +14,6 @@ local label = "meaning of life" local data = { value = 42 } print($"The {label} is {data.value}") -- "The meaning of life is 42" ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20label%20%3D%20%22meaning%20of%20life%22%0D%0Alocal%20data%20%3D%20%7B%20value%20%3D%2042%20%7D%0D%0Aprint(%24%22The%20%7Blabel%7D%20is%20%7Bdata.value%7D%22)%20--%20%22The%20meaning%20of%20life%20is%2042%22) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20label%20%3D%20%22meaning%20of%20life%22%0D%0Alocal%20data%20%3D%20%7B%20value%20%3D%2042%20%7D%0D%0Aprint(%24%22The%20%7Blabel%7D%20is%20%7Bdata.value%7D%22)%20--%20%22The%20meaning%20of%20life%20is%2042%22) As you can see, you declare a string interpolated by prefixing it with the "$" symbol. Brackets can contain any expression. The result of expressions will be converted to a string as with normal concatenation, although note that Pluto supports [boolean concatenation](../QoL%20Improvements/Boolean%20Concatenation) unlike Lua. \ No newline at end of file diff --git a/docs/New Features/Switch Blocks.md b/docs/New Features/Switch Blocks.md index fc3d5d21f..588f081cd 100644 --- a/docs/New Features/Switch Blocks.md +++ b/docs/New Features/Switch Blocks.md @@ -68,7 +68,7 @@ end ``` The `default` case can be placed anywhere in the block. It also supports fallthrough, so remember to use `break` if you place it above any cases. -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20value%20%3D%203%0D%0Aswitch%20value%20do%0D%0A%20%20case%201%3A%0D%0A%20%20case%202%3A%0D%0A%20%20case%203%3A%0D%0A%20%20case%204%3A%0D%0A%20%20case%205%3A%0D%0A%20%20%20%20print%20%22Got%201-5.%22%0D%0A%20%20%20%20break%0D%0A%20%20default%3A%0D%0A%20%20%20%20print%20%22Value%20is%20greater%20than%205.%22%0D%0Aend%0D%0A--%20Break%20jumps%20here.) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20value%20%3D%203%0D%0Aswitch%20value%20do%0D%0A%20%20case%201%3A%0D%0A%20%20case%202%3A%0D%0A%20%20case%203%3A%0D%0A%20%20case%204%3A%0D%0A%20%20case%205%3A%0D%0A%20%20%20%20print%20%22Got%201-5.%22%0D%0A%20%20%20%20break%0D%0A%20%20default%3A%0D%0A%20%20%20%20print%20%22Value%20is%20greater%20than%205.%22%0D%0Aend%0D%0A--%20Break%20jumps%20here.) ## Case Blocks @@ -131,7 +131,7 @@ print(place) --> 1st Note that the case blocks here have their conditions delimited by an arrow (->) instead of a colon (:). -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20place%20%3D%201%0D%0Aplace%20%3D%20switch%20place%20do%0D%0A%20%20%20%20case%201%20-%3E%20%221st%22%0D%0A%20%20%20%20case%202%20-%3E%20%222nd%22%0D%0A%20%20%20%20case%203%20-%3E%20%223rd%22%0D%0A%20%20%20%20default%20-%3E%20%24%22%7Bplace%7Dth%22%0D%0Aend%0D%0Aprint(place)) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20place%20%3D%201%0D%0Aplace%20%3D%20switch%20place%20do%0D%0A%20%20%20%20case%201%20-%3E%20%221st%22%0D%0A%20%20%20%20case%202%20-%3E%20%222nd%22%0D%0A%20%20%20%20case%203%20-%3E%20%223rd%22%0D%0A%20%20%20%20default%20-%3E%20%24%22%7Bplace%7Dth%22%0D%0Aend%0D%0Aprint(place)) Despite not being able to manually fall through, the shorthand fallthrough syntax still works: @@ -149,7 +149,7 @@ print_range(9) --> nil Notice how the `default` case was omitted in this example, so it was implicitly set to `default -> nil`. -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20function%20print_range(value)%0D%0A%20%20%20%20print(switch%20value%20do%0D%0A%20%20%20%20%20%20%20%20case%201%2C%202%2C%203%20-%3E%20%221-3%22%0D%0A%20%20%20%20%20%20%20%20case%204%2C%205%2C%206%20-%3E%20%224-6%22%0D%0A%20%20%20%20end)%0D%0Aend%0D%0Aprint_range(1)%20--%3E%20%221-3%22%0D%0Aprint_range(6)%20--%3E%20%224-6%22%0D%0Aprint_range(9)%20--%3E%20nil) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20function%20print_range(value)%0D%0A%20%20%20%20print(switch%20value%20do%0D%0A%20%20%20%20%20%20%20%20case%201%2C%202%2C%203%20-%3E%20%221-3%22%0D%0A%20%20%20%20%20%20%20%20case%204%2C%205%2C%206%20-%3E%20%224-6%22%0D%0A%20%20%20%20end)%0D%0Aend%0D%0Aprint_range(1)%20--%3E%20%221-3%22%0D%0Aprint_range(6)%20--%3E%20%224-6%22%0D%0Aprint_range(9)%20--%3E%20nil) ## Using Compatibility Mode? You may need to use `pluto_switch` instead of `switch`. Alternatively, `pluto_use switch` will enable the keyword independently of environment settings. diff --git a/docs/New Features/Ternary Expressions.md b/docs/New Features/Ternary Expressions.md index 033e141b5..d6568bc1a 100644 --- a/docs/New Features/Ternary Expressions.md +++ b/docs/New Features/Ternary Expressions.md @@ -13,7 +13,7 @@ end ```pluto showLineNumbers title="New Code" local max = a > b ? a : b ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20a%20%3D%206%0Alocal%20b%20%3D%209%0A%0Alocal%20max%20%3D%20a%20%3E%20b%20%3F%20a%20%3A%20b%0A%0Aprint(max)) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20a%20%3D%206%0Alocal%20b%20%3D%209%0A%0Alocal%20max%20%3D%20a%20%3E%20b%20%3F%20a%20%3A%20b%0A%0Aprint(max)) ## Doesn't Lua already have ternaries? diff --git a/docs/New Features/Try-Catch Statement.md b/docs/New Features/Try-Catch Statement.md index 204e0913d..7f6a84d0d 100644 --- a/docs/New Features/Try-Catch Statement.md +++ b/docs/New Features/Try-Catch Statement.md @@ -31,7 +31,7 @@ print(try_get_fruit_rating("cucumber")) --> -10 print(try_get_fruit_rating("car")) --> nil ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20function%20get_fruit_rating(fruit)%0D%0A%20%20%20%20return%20switch%20fruit%20do%0D%0A%20%20%20%20%20%20%20%20case%20%22apple%22%20-%3E%208%0D%0A%20%20%20%20%20%20%20%20case%20%22banana%22%20-%3E%207%0D%0A%20%20%20%20%20%20%20%20case%20%22orange%22%20-%3E%209%0D%0A%20%20%20%20%20%20%20%20case%20%22mango%22%20-%3E%2010%0D%0A%20%20%20%20%20%20%20%20case%20%22grape%22%20-%3E%206%0D%0A%20%20%20%20%20%20%20%20case%20%22strawberry%22%20-%3E%209%0D%0A%20%20%20%20%20%20%20%20case%20%22cucumber%22%2C%20%22tomato%22%20-%3E%20error(%22What%20are%20you%2C%20a%20botanist%3F%22)%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20function%20try_get_fruit_rating(fruit)%0D%0A%20%20%20%20try%0D%0A%20%20%20%20%20%20%20%20return%20get_fruit_rating(fruit)%0D%0A%20%20%20%20catch%20e%20then%0D%0A%20%20%20%20%20%20%20%20if%20e%3Afind(%22What%20are%20you%2C%20a%20botanist%3F%22)%20then%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20-10%0D%0A%20%20%20%20%20%20%20%20end%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Aprint(try_get_fruit_rating(%22apple%22))%20--%3E%208%0D%0Aprint(try_get_fruit_rating(%22cucumber%22))%20--%3E%20-10%0D%0Aprint(try_get_fruit_rating(%22car%22))%20--%3E%20nil) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20function%20get_fruit_rating(fruit)%0D%0A%20%20%20%20return%20switch%20fruit%20do%0D%0A%20%20%20%20%20%20%20%20case%20%22apple%22%20-%3E%208%0D%0A%20%20%20%20%20%20%20%20case%20%22banana%22%20-%3E%207%0D%0A%20%20%20%20%20%20%20%20case%20%22orange%22%20-%3E%209%0D%0A%20%20%20%20%20%20%20%20case%20%22mango%22%20-%3E%2010%0D%0A%20%20%20%20%20%20%20%20case%20%22grape%22%20-%3E%206%0D%0A%20%20%20%20%20%20%20%20case%20%22strawberry%22%20-%3E%209%0D%0A%20%20%20%20%20%20%20%20case%20%22cucumber%22%2C%20%22tomato%22%20-%3E%20error(%22What%20are%20you%2C%20a%20botanist%3F%22)%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Alocal%20function%20try_get_fruit_rating(fruit)%0D%0A%20%20%20%20try%0D%0A%20%20%20%20%20%20%20%20return%20get_fruit_rating(fruit)%0D%0A%20%20%20%20catch%20e%20then%0D%0A%20%20%20%20%20%20%20%20if%20e%3Afind(%22What%20are%20you%2C%20a%20botanist%3F%22)%20then%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20-10%0D%0A%20%20%20%20%20%20%20%20end%0D%0A%20%20%20%20end%0D%0Aend%0D%0A%0D%0Aprint(try_get_fruit_rating(%22apple%22))%20--%3E%208%0D%0Aprint(try_get_fruit_rating(%22cucumber%22))%20--%3E%20-10%0D%0Aprint(try_get_fruit_rating(%22car%22))%20--%3E%20nil) ## Using Compatibility Mode? diff --git a/docs/New Operators.md b/docs/New Operators.md index 0320e541c..2d6d5e67b 100644 --- a/docs/New Operators.md +++ b/docs/New Operators.md @@ -156,7 +156,7 @@ http.request("https://httpbin.org/get") --> ["url"] = string(23) "https://httpbin.org/get", --> } ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20%7B%20http%2C%20json%20%7D%20%3D%20require%20%22pluto%3A*%22%0D%0A%0D%0Ahttp.request(%22https%3A%2F%2Fhttpbin.org%2Fget%22)%0D%0A%7C%3E%20json.decode%0D%0A%7C%3E%20dumpvar%0D%0A%7C%3E%20print%0D%0A) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20%7B%20http%2C%20json%20%7D%20%3D%20require%20%22pluto%3A*%22%0D%0A%0D%0Ahttp.request(%22https%3A%2F%2Fhttpbin.org%2Fget%22)%0D%0A%7C%3E%20json.decode%0D%0A%7C%3E%20dumpvar%0D%0A%7C%3E%20print%0D%0A) The HTTP-to-print pipeline here would otherwise be written like this: ```pluto print(dumpvar(json.decode((http.request("https://httpbin.org/get"))))) @@ -172,7 +172,7 @@ producer() |> tonumber|16| |> print --> 16 ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20producer%20%3D%20%7C%7C%20-%3E%20%2210%22%0D%0A%0D%0Aproducer()%0D%0A%7C%3E%20tonumber%7C16%7C%0D%0A%7C%3E%20print%20--%3E%2016%0D%0A) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20producer%20%3D%20%7C%7C%20-%3E%20%2210%22%0D%0A%0D%0Aproducer()%0D%0A%7C%3E%20tonumber%7C16%7C%0D%0A%7C%3E%20print%20--%3E%2016%0D%0A) ### Methods Calls There is specialized syntax for method calls with the pipe operator, too: @@ -190,7 +190,7 @@ producer() |> obj:multiply |> print --> 42 ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20producer%20%3D%20%7C%7C%20-%3E%2021%0D%0A%0D%0Alocal%20obj%20%3D%20%7B%0D%0A%20%20%20%20function%20multiply(value)%0D%0A%20%20%20%20%20%20%20%20return%20value%20*%20self.factor%0D%0A%20%20%20%20end%0D%0A%7D%0D%0Aobj.factor%20%3D%202%0D%0A%0D%0Aproducer()%0D%0A%7C%3E%20obj%3Amultiply%0D%0A%7C%3E%20print%20--%3E%2042%0D%0A) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20producer%20%3D%20%7C%7C%20-%3E%2021%0D%0A%0D%0Alocal%20obj%20%3D%20%7B%0D%0A%20%20%20%20function%20multiply(value)%0D%0A%20%20%20%20%20%20%20%20return%20value%20*%20self.factor%0D%0A%20%20%20%20end%0D%0A%7D%0D%0Aobj.factor%20%3D%202%0D%0A%0D%0Aproducer()%0D%0A%7C%3E%20obj%3Amultiply%0D%0A%7C%3E%20print%20--%3E%2042%0D%0A) ### Anonymous Functions The righthand side of the pipe operator can also be an anonymous function, allowing for more advanced usage like this: @@ -202,4 +202,4 @@ producer() --> The result was 42 ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20producer%20%3D%20%7C%7C%20-%3E%2042%0D%0A%0D%0Aproducer()%0D%0A%7C%3E%20%7Cres%7C%20-%3E%20print(%24%22The%20result%20was%20%7Bres%7D%22)%0D%0A%0D%0A--%3E%20The%20result%20was%2042%0D%0A) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20producer%20%3D%20%7C%7C%20-%3E%2042%0D%0A%0D%0Aproducer()%0D%0A%7C%3E%20%7Cres%7C%20-%3E%20print(%24%22The%20result%20was%20%7Bres%7D%22)%0D%0A%0D%0A--%3E%20The%20result%20was%2042%0D%0A) diff --git a/docs/Runtime Environment/Exception.md b/docs/Runtime Environment/Exception.md index e2b813b35..be37d853e 100644 --- a/docs/Runtime Environment/Exception.md +++ b/docs/Runtime Environment/Exception.md @@ -23,4 +23,4 @@ Not implemented script.pluto:2 ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=try%0A%20%20%20%20new%20exception(%22Not%20implemented%22)%0Acatch%20e%20then%0A%20%20%20%20print(e)%20--%20same%20as%20error(%22Not%20implemented%22)%0A%20%20%20%20print(e.what)%0A%20%20%20%20print(e.where)%0Aend) +#### [Try It Yourself](https://plutolang.github.io/web/#code=try%0A%20%20%20%20new%20exception(%22Not%20implemented%22)%0Acatch%20e%20then%0A%20%20%20%20print(e)%20--%20same%20as%20error(%22Not%20implemented%22)%0A%20%20%20%20print(e.what)%0A%20%20%20%20print(e.where)%0Aend) diff --git a/docs/Runtime Environment/HTTP.md b/docs/Runtime Environment/HTTP.md index 1908a03f2..3292d3097 100644 --- a/docs/Runtime Environment/HTTP.md +++ b/docs/Runtime Environment/HTTP.md @@ -40,7 +40,7 @@ if os.platform != "wasm" then end print(body) ``` -#### [Try It Yourself](https://pluto-lang.org/web/#code=local%20http%20%3D%20require%20%22pluto%3Ahttp%22%0D%0Alocal%20body%2C%20status_code%2C%20headers%2C%20status_text%20%3D%20http.request(%22https%3A%2F%2Fhttpbin.org%2Fanything%22)%0D%0Aprint(status_code..%22%20%22..status_text)%0D%0Aif%20os.platform%20!%3D%20%22wasm%22%20then%0D%0A%20%20%20%20print(dumpvar(headers))%0D%0Aend%0D%0Aprint(body)) +#### [Try It Yourself](https://plutolang.github.io/web/#code=local%20http%20%3D%20require%20%22pluto%3Ahttp%22%0D%0Alocal%20body%2C%20status_code%2C%20headers%2C%20status_text%20%3D%20http.request(%22https%3A%2F%2Fhttpbin.org%2Fanything%22)%0D%0Aprint(status_code..%22%20%22..status_text)%0D%0Aif%20os.platform%20!%3D%20%22wasm%22%20then%0D%0A%20%20%20%20print(dumpvar(headers))%0D%0Aend%0D%0Aprint(body)) --- ### `http.hasconnection` diff --git a/docs/Runtime Environment/Socket.md b/docs/Runtime Environment/Socket.md index 70f0189f2..2c0ef2a24 100644 --- a/docs/Runtime Environment/Socket.md +++ b/docs/Runtime Environment/Socket.md @@ -93,9 +93,9 @@ If called inside of a coroutine, this function yields. Otherwise, it blocks. ```pluto local socket = require "pluto:socket" -local s = socket.connect("pluto-lang.org", 443) -assert(s:starttls("pluto-lang.org"), "Failed to establish secure connection.") -s:send("GET / HTTP/1.1\r\nHost: pluto-lang.org\r\nConnection: close\r\n\r\n") +local s = socket.connect("plutolang.github.io", 443) +assert(s:starttls("plutolang.github.io"), "Failed to establish secure connection.") +s:send("GET / HTTP/1.1\r\nHost: plutolang.github.io\r\nConnection: close\r\n\r\n") while data := s:recv() do print(data) end diff --git a/docusaurus.config.js b/docusaurus.config.js index 0706d1795..36f694493 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -7,7 +7,7 @@ const codeTheme = require('./src/theme/monokai'); const config = { title: 'Pluto', tagline: 'A superset of Lua 5.4 with a focus on general-purpose programming.', - url: 'https://pluto-lang.org', + url: 'https://plutolang.github.io', baseUrl: '/', onBrokenLinks: 'warn', onBrokenMarkdownLinks: 'warn',