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
+29-8Lines changed: 29 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -16,19 +16,19 @@ Pluto adds the following reserved tokens:
16
16
-`try`
17
17
-`catch`
18
18
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).
19
+
Which means you can't use them as identifiers. They can still be used with short-hand table indexes and goto labels because Pluto [allows reserved keywords to be used in those contexts](QoL%20Improvements/Reserved%20Identifiers).
20
20
21
21
### How to fix it?
22
22
All of these incompatible keywords can be disabled:
23
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)
24
+
-**For Scripters:**Usage of `pluto_use` in the source files.
25
25
-**For Users:** Pass the `-c` flag to `pluto` or `plutoc`.
26
26
27
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.
28
+
Scripters are given final say in how Compatibility Mode works within their scripts.
29
29
30
-
### Compile-time Configuration
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.
30
+
### Compile-time Configuration (pluto_use)
31
+
You can change the meaning of Pluto's reserved tokens at any point in your scripts using the `--@pluto_use`comment or `pluto_use` statement.
32
32
33
33
For example, to disable all non-compatible keywords except for `switch`:
34
34
```pluto
@@ -41,14 +41,35 @@ It is also possible to specify a version number, which is a shorthand for the ke
So, writing a portable script that makes use of Pluto 0.8.0's features simply requires this at the beginning:
44
+
So, writing a portable script that only makes use of Pluto 0.8.0's features requires this at the beginning:
45
45
```pluto
46
46
pluto_use "0.8.0"
47
47
```
48
48
49
-
We recommend you always place a `pluto_use` configuration at the beginning of your scripts for two reasons:
49
+
This feature also supports quick encompassing of optional features. So, instead of:
50
+
```pluto
51
+
pluto_use "0.8.0", global
52
+
```
53
+
You can use a '+' after the version number to also enable all of the optional features. As of 0.9.0, the only optional feature is [explicit globals](New%20Features/Explicit%20Globals) (`global`).
54
+
```pluto
55
+
pluto_use "0.9.0+"
56
+
-- The same as pluto_use "0.9.0", global
57
+
```
58
+
59
+
For module developers and scripts which may be used in future versions of Pluto, we recommend you use `pluto_use` for two reasons:
50
60
-**Portability.** This will override the compatibility mode settings compiled into Pluto so your script will be parsed identically in all Pluto environments.
51
61
-**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.
52
62
53
63
### 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`.
64
+
Another way of using Pluto's features regardless of compatibility mode is by prefixing the keyword with `pluto_`. For example, `switch` becomes `pluto_switch`. These Compatibility Mode variants will always be valid, even when Compatibility Mode is disabled.
0 commit comments