You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Compatibility.md
+17-11Lines changed: 17 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ sidebar_position: 10
3
3
---
4
4
5
5
## How compatible with Lua is Pluto?
6
-
Pluto is 99.9% compatible with most Lua source code. However, it's imperfect. Due to that, Pluto implements several compatibility macros.
6
+
Pluto is compatible with most Lua source code. However, it's imperfect. Due to that, Pluto has several compatibility options.
7
7
### Where are the incompatibilities?
8
8
Pluto adds the following reserved tokens:
9
9
-`switch`
@@ -18,13 +18,17 @@ Pluto adds the following reserved tokens:
18
18
19
19
Which means you can't use them as variable names or for function calls. They can still be used with short-hand table indexes and goto labels though, because Pluto [removes the restriction from them](QoL%20Improvements/Reserved%20Identifiers).
20
20
21
-
However, we have a simple solution for this: Compatibility Mode. This allows integrators to disable Pluto's reserved tokens. Integrators: Check your `luaconf.h` file to find the relevant macros under the "Compatibility" heading.
21
+
### How to fix it?
22
+
All of these incompatible keywords can be disabled:
23
+
-**For Integrators:** Check your `luaconf.h` file to find the relevant macros under the "Compatibility" heading.
24
+
-**For Scripters:** Place `-- @pluto_use * = false` at the top of the source file. [Read more...](#compile-time-configuration)
25
+
-**For Users:** Pass the `-c` flag to `pluto` or `plutoc`.
22
26
23
-
## Writing Scripts Under Compatibility Mode
24
-
Obviously, you want to use Pluto's features, so how can you do it if the Pluto environment has all of its tokens disabled? The secret is that each reserved token mentioned above has a portable variant with a `pluto_` prefix. For example, `switch` has a twin called `pluto_switch` that is always valid.
27
+
## For Scripters
28
+
Because the Pluto environment your script is running in may have disabled some keywords for compatibility's sake, let's go over the portability and compatibility options given to you by Pluto.
25
29
26
30
### Compile-time Configuration
27
-
You can also change the meaning of Pluto's reserved tokens at any point in your scripts using the `@pluto_use` annotation or `pluto_use` statement.
31
+
You can change the meaning of Pluto's reserved tokens at any point in your scripts using the `@pluto_use` annotation or `pluto_use` statement.
28
32
29
33
For example, to disable all non-compatible keywords except for `switch`:
30
34
```pluto
@@ -37,12 +41,14 @@ It is also possible to specify a version number, which is a shorthand for the ke
We recommend scripters use the `@pluto_use` annotation at the beginning of their scripts for two reasons:
44
+
So, writing a portable script that makes use of Pluto 0.8.0's features simply requires this at the beginning:
45
+
```pluto
46
+
pluto_use "0.8.0"
47
+
```
48
+
49
+
We recommend you always place a `pluto_use` configuration at the beginning of your scripts for two reasons:
42
50
-**Portability.** This will override the compatibility mode settings compiled into Pluto so your script will be parsed identically in all Pluto environments.
43
51
-**Proactive compatibility.** Any keywords added by future versions of Pluto will also be put in compatibility mode by these statements, so in the off-chance your script uses a future reserved keyword as a variable name, it would still parse as you intended when you wrote it.
44
52
45
-
Plus, it's as simple as this:
46
-
```pluto
47
-
-- @pluto_use "0.8.0"
48
-
```
53
+
### Compatible Keywords
54
+
Another way of using Pluto's features regardless of compatibility mode is by prefixing the keyword with `pluto_`. For example, `switch` becomes `pluto_switch`.
0 commit comments