<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://pico8wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=107.204.125.41</id>
	<title>Pico-8 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://pico8wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=107.204.125.41"/>
	<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Special:Contributions/107.204.125.41"/>
	<updated>2026-11-26T12:21:40Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Tokens&amp;diff=12115</id>
		<title>Tokens</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Tokens&amp;diff=12115"/>
		<updated>2022-07-27T23:09:01Z</updated>

		<summary type="html">&lt;p&gt;107.204.125.41: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the stricter limits PICO-8 places on its carts&#039; code is that they must contain no more than 8192 tokens.&lt;br /&gt;
&lt;br /&gt;
A token is one of:&lt;br /&gt;
&lt;br /&gt;
* A literal value, such as &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, any number (e.g. &amp;lt;code&amp;gt;123&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;0xff.ff&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;~1e4&amp;lt;/code&amp;gt;), or any string (of any size).&lt;br /&gt;
* A variable or operator&lt;br /&gt;
* An opening bracket (&#039;(&#039;, &#039;[&#039;, &#039;{&#039;)&lt;br /&gt;
* A keyword, with the exception of &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In particular, the following are not counted as tokens:&lt;br /&gt;
&lt;br /&gt;
* The comma (,), semicolon (;), period (.), colon (:), and double-colon (::)&lt;br /&gt;
* Closing brackets (&#039;)&#039;, &#039;]&#039;, &#039;}&#039;)&lt;br /&gt;
* The &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; keywords&lt;br /&gt;
* The unary minus (-) and complement (~) operators when applied on a numeric literal&lt;br /&gt;
&lt;br /&gt;
== Token saving tips ==&lt;br /&gt;
Common token saving tips that apply to most situations:&lt;br /&gt;
&lt;br /&gt;
* Instead of assigning one variable per statement, combine assignments into a single statement, saving on the &#039;=&#039; token: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;a=1 b=2 c=3&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;a,b,c = 1,2,3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a=1; local b=2&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = 1,2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Trailing nils can be omitted when assigning variables: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3,nil,nil&amp;lt;/code&amp;gt; -&amp;gt; &amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = nil,nil&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b&amp;lt;/code&amp;gt;&lt;br /&gt;
**Declaring a global with a value of nil at program start is equivalent to not declaring it at all. It is worth putting comments to keep track of these &amp;quot;undeclared&amp;quot; variables.&lt;br /&gt;
&lt;br /&gt;
*Usually trailing nils can be omitted when calling functions: &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;f(a,b,nil,nil)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt; &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;Beware that some functions do check the number of arguments provided, and differ in behaviour between a nil and an unprovided argument.&lt;br /&gt;
&lt;br /&gt;
* When calling a function with only 1 argument, and that argument is a string or table literal, the parentheses can be omitted to save a token: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(&amp;quot;smart&amp;quot;)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f &amp;quot;smart&amp;quot;&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f({1,2,3})&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f {1,2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In many cases, &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; can be used instead of &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; for boolean variables and parameters, allowing the use of other tricks in this list that allow omitting nil. &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,false)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = true, false&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = true&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that while most operators and functions operating on booleans accept &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, a small few (like direct comparison via &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt;) can still break this approach.&lt;br /&gt;
&lt;br /&gt;
* When creating functions, move any parameters that may not need to be specified or that can have a good default value to the end of the parameter list, so that callers can usually avoid passing them.&lt;br /&gt;
&lt;br /&gt;
* Avoid defining constants or computing constants, preferring to use a single constant instead. &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;hour=60*60; f(hour); g(hour)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(3600); g(3600)&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that this can make changing those constants harder, so prefer to do it only once after being sure the constants won&#039;t change anymore.&lt;br /&gt;
&lt;br /&gt;
* Use a local variable to save the value of a computation that will be used again later, when doing so will save tokens. (The more complex the computation and the more it is repeated, the more likely that a local will save tokens)   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a+1); g(a+1); h(a+1)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ap1=a+1; f(ap1); g(ap1); h(ap1)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a.x, a.x+1, a.x+5, a.x+10, a.x+12); g(a.x, -a.x)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ax=a.x; f(ax, ax+1, ax+5, ax+10, ax+12); g(ax, -ax)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For constant tables of numbers or strings, a string literal may be &amp;lt;code&amp;gt;split()&amp;lt;/code&amp;gt; to save many tokens. &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;t={1,2,3,10,9,8,99,-1}&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;t=split &amp;quot;1,2,3,10,9,8,99,-1&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; when possible: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;if (f()) a=x else a=y&amp;lt;/code&amp;gt; →  &amp;lt;code&amp;gt;a = f() and x or y&amp;lt;/code&amp;gt; (Beware: this only works if &amp;lt;var&amp;gt;x&amp;lt;/var&amp;gt; can never be &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;!)&lt;br /&gt;
&lt;br /&gt;
* Prefer member access over array indexing: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;tbl[&#039;special&#039;]&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;tbl.special&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;An object like &amp;lt;code&amp;gt;{a=1,b=2,c=3}&amp;lt;/code&amp;gt; takes fewer tokens to read/write values from that &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt;, though the latter takes fewer tokens to construct. This is usually beneficial as objects usually need to be accessed in multiple places but only need to be constructed in one function.&lt;br /&gt;
&lt;br /&gt;
* Make use of API default arguments, especially with math calls where they default to 0: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;x=max(x,0); y=min(y,0); z=mid(z,0,1)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;x=max(x); y=min(y); z=mid(z,1)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Miscellaneous token saving tips for specific situations:&lt;br /&gt;
&lt;br /&gt;
* It is possible to save 1 token by converting &amp;lt;code&amp;gt;pairs(mytable)&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;next, mytable&amp;lt;/code&amp;gt; (which is equivalent, with the minor exception that &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; calls the &amp;lt;code&amp;gt;__pairs()&amp;lt;/code&amp;gt; metamethod if one is implemented in &amp;lt;var&amp;gt;mytable&amp;lt;/var&amp;gt;)&lt;br /&gt;
[[Category:Research]]&lt;/div&gt;</summary>
		<author><name>107.204.125.41</name></author>
	</entry>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Tokens&amp;diff=12111</id>
		<title>Tokens</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Tokens&amp;diff=12111"/>
		<updated>2022-06-12T20:01:57Z</updated>

		<summary type="html">&lt;p&gt;107.204.125.41: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the stricter limits PICO-8 places on its carts&#039; code is that they must contain no more than 8192 tokens.&lt;br /&gt;
&lt;br /&gt;
A token is one of:&lt;br /&gt;
&lt;br /&gt;
* A literal value, such as &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, any number (e.g. &amp;lt;code&amp;gt;123&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;0xff.ff&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;~1e4&amp;lt;/code&amp;gt;), or any string (of any size).&lt;br /&gt;
* A variable or operator&lt;br /&gt;
* An opening bracket (&#039;(&#039;, &#039;[&#039;, &#039;{&#039;)&lt;br /&gt;
* A keyword, with the exception of &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In particular, the following are not counted as tokens:&lt;br /&gt;
&lt;br /&gt;
* The comma (,), semicolon (;), period (.), colon (:), and double-colon (::)&lt;br /&gt;
* Closing brackets (&#039;)&#039;, &#039;]&#039;, &#039;}&#039;)&lt;br /&gt;
* The &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; keywords&lt;br /&gt;
* The unary minus (-) and complement (~) operators when applied on a numeric literal&lt;br /&gt;
&lt;br /&gt;
== Token saving tips ==&lt;br /&gt;
Common token saving tips that apply to most situations:&lt;br /&gt;
&lt;br /&gt;
* Instead of assigning one variable per statement, combine assignments into a single statement, saving on the &#039;=&#039; token: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;a=1 b=2 c=3&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;a,b,c = 1,2,3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a=1; local b=2&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = 1,2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can omit trailing nils when assigning variables: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3,nil,nil&amp;lt;/code&amp;gt; -&amp;gt; &amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = nil,nil&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b&amp;lt;/code&amp;gt;&lt;br /&gt;
**You can also omit the declaration entirely if it is a global and it will be equivalent to declaring it as nil. It is worth commenting so you do not lose track of your variables.&lt;br /&gt;
&lt;br /&gt;
*You can usually omit trailing nils when calling functions:   &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;f(a,b,nil,nil)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt; &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;Beware that some functions do check the number of arguments provided, and differ in behaviour between a nil and an unprovided argument&lt;br /&gt;
&lt;br /&gt;
* When calling a function with only 1 argument, and that argument is a string or table literal, you can omit the parentheses to save a token:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(&amp;quot;smart&amp;quot;)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f &amp;quot;smart&amp;quot;&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f({1,2,3})&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f {1,2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can usually pass &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; to boolean variables and parameters, allowing you to use other tricks in this list that allow omitting nil.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,false)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = true, false&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = true&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that while most operators and functions operating on booleans accept &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, a small few (like direct comparison via &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt;) can still break this approach&lt;br /&gt;
&lt;br /&gt;
* When creating your own functions, move any parameters that may not need to be specified or that can have a good default value to the end of the parameter list, so that callers can usually avoid passing them.&lt;br /&gt;
&lt;br /&gt;
* Avoid defining constants or computing constants, preferring to use a single constant instead.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;hour=60*60; f(hour); g(hour)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(3600); g(3600)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that this can make changing those constants harder, so you may want to do it only once you&#039;re sure the constants won&#039;t change anymore.&lt;br /&gt;
&lt;br /&gt;
* Use a local to save the value of a repeated computation, when doing so will save tokens. (The more complex the computation and the more it is repeated, the more likely that a local will save tokens)   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a+1); g(a+1); h(a+1)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ap1=a+1; f(ap1); g(ap1); h(ap1)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a.x, a.x+1, a.x+5, a.x+10, a.x+12); g(a.x, -a.x)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ax=a.x; f(ax, ax+1, ax+5, ax+10, ax+12); g(ax, -ax)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For constant tables of numbers or strings, you can use a string literal with &amp;lt;code&amp;gt;split()&amp;lt;/code&amp;gt; to save many tokens.  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;t={1,2,3,10,9,8,99,-1}&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;t=split &amp;quot;1,2,3,10,9,8,99,-1&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; when possible:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;if (f()) a=x else a=y&amp;lt;/code&amp;gt; →  &amp;lt;code&amp;gt;a = f() and x or y&amp;lt;/code&amp;gt; (Beware: only works if x can never be false or nil!)&lt;br /&gt;
&lt;br /&gt;
* Prefer member access over array indexing:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;tbl[&#039;special&#039;]&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;tbl.special&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;An object like &amp;lt;code&amp;gt;{a=1,b=2,c=3}&amp;lt;/code&amp;gt; takes fewer tokens to read/write values from that &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt;, though the latter takes fewer tokens to construct. This is usually beneficial as objects usually need to be accessed in multiple places but only need to be constructed in one function.&lt;br /&gt;
&lt;br /&gt;
Miscallenous token saving tips for specific situations:&lt;br /&gt;
&lt;br /&gt;
* You can save 1 token by converting &amp;lt;code&amp;gt;pairs(mytable)&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;next, mytable&amp;lt;/code&amp;gt; (which is equivalent, with the minor exception that pairs calls the &amp;lt;code&amp;gt;__pairs&amp;lt;/code&amp;gt; metamethod if you implemented one)&lt;br /&gt;
[[Category:Research]]&lt;/div&gt;</summary>
		<author><name>107.204.125.41</name></author>
	</entry>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Tokens&amp;diff=12110</id>
		<title>Tokens</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Tokens&amp;diff=12110"/>
		<updated>2022-06-12T19:53:42Z</updated>

		<summary type="html">&lt;p&gt;107.204.125.41: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the stricter limits PICO-8 places on its carts&#039; code is that they must contain no more than 8192 tokens.&lt;br /&gt;
&lt;br /&gt;
A token is one of:&lt;br /&gt;
&lt;br /&gt;
* A literal value, such as &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, any number (e.g. &amp;lt;code&amp;gt;123&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;0xff.ff&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;~1e4&amp;lt;/code&amp;gt;), or any string (of any size).&lt;br /&gt;
* A variable or operator&lt;br /&gt;
* An opening bracket (&#039;(&#039;, &#039;[&#039;, &#039;{&#039;)&lt;br /&gt;
* A keyword, with the exception of &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In particular, the following are not counted as tokens:&lt;br /&gt;
&lt;br /&gt;
* The comma (,), semicolon (;), period (.), colon (:), and double-colon (::)&lt;br /&gt;
* Closing brackets (&#039;)&#039;, &#039;]&#039;, &#039;}&#039;)&lt;br /&gt;
* The &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; keywords&lt;br /&gt;
* The unary minus (-) and complement (~) operators when applied on a numeric literal&lt;br /&gt;
&lt;br /&gt;
== Token saving tips ==&lt;br /&gt;
Common token saving tips that apply to most situations:&lt;br /&gt;
&lt;br /&gt;
* Instead of assigning one variable per statement, combine assignments into a single statement, saving on the &#039;=&#039; token: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;a=1 b=2 c=3&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;a,b,c = 1,2,3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a=1; local b=2&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = 1,2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can omit trailing nils when assigning variables: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3,nil,nil&amp;lt;/code&amp;gt; -&amp;gt; &amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = nil,nil&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b&amp;lt;/code&amp;gt;&lt;br /&gt;
**You can also omit the declaration entirely and it will be equivalent to declaring it as nil. It is worth commenting so you do not lose track of your variables.&lt;br /&gt;
&lt;br /&gt;
*You can usually omit trailing nils when calling functions:   &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;code&amp;gt;f(a,b,nil,nil)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt; &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;Beware that some functions do check the number of arguments provided, and differ in behaviour between a nil and an unprovided argument&lt;br /&gt;
&lt;br /&gt;
* When calling a function with only 1 argument, and that argument is a string or table literal, you can omit the parentheses to save a token:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(&amp;quot;smart&amp;quot;)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f &amp;quot;smart&amp;quot;&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f({1,2,3})&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f {1,2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can usually pass &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; to boolean variables and parameters, allowing you to use other tricks in this list that allow omitting nil.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,false)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = true, false&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = true&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that while most operators and functions operating on booleans accept &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, a small few (like direct comparison via &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt;) can still break this approach&lt;br /&gt;
&lt;br /&gt;
* When creating your own functions, move any parameters that may not need to be specified or that can have a good default value to the end of the parameter list, so that callers can usually avoid passing them.&lt;br /&gt;
&lt;br /&gt;
* Avoid defining constants or computing constants, preferring to use a single constant instead.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;hour=60*60; f(hour); g(hour)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(3600); g(3600)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that this can make changing those constants harder, so you may want to do it only once you&#039;re sure the constants won&#039;t change anymore.&lt;br /&gt;
&lt;br /&gt;
* Use a local to save the value of a repeated computation, when doing so will save tokens. (The more complex the computation and the more it is repeated, the more likely that a local will save tokens)   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a+1); g(a+1); h(a+1)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ap1=a+1; f(ap1); g(ap1); h(ap1)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a.x, a.x+1, a.x+5, a.x+10, a.x+12); g(a.x, -a.x)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ax=a.x; f(ax, ax+1, ax+5, ax+10, ax+12); g(ax, -ax)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For constant tables of numbers or strings, you can use a string literal with &amp;lt;code&amp;gt;split()&amp;lt;/code&amp;gt; to save many tokens.  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;t={1,2,3,10,9,8,99,-1}&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;t=split &amp;quot;1,2,3,10,9,8,99,-1&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; when possible:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;if (f()) a=x else a=y&amp;lt;/code&amp;gt; →  &amp;lt;code&amp;gt;a = f() and x or y&amp;lt;/code&amp;gt; (Beware: only works if x can never be false or nil!)&lt;br /&gt;
&lt;br /&gt;
* Prefer member access over array indexing:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;tbl[&#039;special&#039;]&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;tbl.special&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;An object like &amp;lt;code&amp;gt;{a=1,b=2,c=3}&amp;lt;/code&amp;gt; takes fewer tokens to read/write values from that &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt;, though the latter takes fewer tokens to construct. This is usually beneficial as objects usually need to be accessed in multiple places but only need to be constructed in one function.&lt;br /&gt;
&lt;br /&gt;
Miscallenous token saving tips for specific situations:&lt;br /&gt;
&lt;br /&gt;
* You can save 1 token by converting &amp;lt;code&amp;gt;pairs(mytable)&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;next, mytable&amp;lt;/code&amp;gt; (which is equivalent, with the minor exception that pairs calls the &amp;lt;code&amp;gt;__pairs&amp;lt;/code&amp;gt; metamethod if you implemented one)&lt;br /&gt;
[[Category:Research]]&lt;/div&gt;</summary>
		<author><name>107.204.125.41</name></author>
	</entry>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Tokens&amp;diff=12109</id>
		<title>Tokens</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Tokens&amp;diff=12109"/>
		<updated>2022-06-12T19:52:48Z</updated>

		<summary type="html">&lt;p&gt;107.204.125.41: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the stricter limits PICO-8 places on its carts&#039; code is that they must contain no more than 8192 tokens.&lt;br /&gt;
&lt;br /&gt;
A token is one of:&lt;br /&gt;
&lt;br /&gt;
* A literal value, such as &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, any number (e.g. &amp;lt;code&amp;gt;123&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;0xff.ff&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;~1e4&amp;lt;/code&amp;gt;), or any string (of any size).&lt;br /&gt;
* A variable or operator&lt;br /&gt;
* An opening bracket (&#039;(&#039;, &#039;[&#039;, &#039;{&#039;)&lt;br /&gt;
* A keyword, with the exception of &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In particular, the following are not counted as tokens:&lt;br /&gt;
&lt;br /&gt;
* The comma (,), semicolon (;), period (.), colon (:), and double-colon (::)&lt;br /&gt;
* Closing brackets (&#039;)&#039;, &#039;]&#039;, &#039;}&#039;)&lt;br /&gt;
* The &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; keywords&lt;br /&gt;
* The unary minus (-) and complement (~) operators when applied on a numeric literal&lt;br /&gt;
&lt;br /&gt;
== Token saving tips ==&lt;br /&gt;
Common token saving tips that apply to most situations:&lt;br /&gt;
&lt;br /&gt;
* Instead of assigning one variable per statement, combine assignments into a single statement, saving on the &#039;=&#039; token: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;a=1 b=2 c=3&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;a,b,c = 1,2,3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a=1; local b=2&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = 1,2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can omit trailing nils when assigning variables: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3,nil,nil&amp;lt;/code&amp;gt; -&amp;gt; &amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = nil,nil&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b&amp;lt;/code&amp;gt;&lt;br /&gt;
You can also omit the declaration entirely and it will be equivalent to declaring it as nil. It is worth commenting so you do not lose track of your variables.&lt;br /&gt;
* You can usually omit trailing nils when calling functions:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,nil,nil)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that some functions do check the number of arguments provided, and differ in behaviour between a nil and an unprovided argument&lt;br /&gt;
&lt;br /&gt;
* When calling a function with only 1 argument, and that argument is a string or table literal, you can omit the parentheses to save a token:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(&amp;quot;smart&amp;quot;)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f &amp;quot;smart&amp;quot;&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f({1,2,3})&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f {1,2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can usually pass &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; to boolean variables and parameters, allowing you to use other tricks in this list that allow omitting nil.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,false)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = true, false&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = true&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that while most operators and functions operating on booleans accept &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, a small few (like direct comparison via &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt;) can still break this approach&lt;br /&gt;
&lt;br /&gt;
* When creating your own functions, move any parameters that may not need to be specified or that can have a good default value to the end of the parameter list, so that callers can usually avoid passing them.&lt;br /&gt;
&lt;br /&gt;
* Avoid defining constants or computing constants, preferring to use a single constant instead.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;hour=60*60; f(hour); g(hour)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(3600); g(3600)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that this can make changing those constants harder, so you may want to do it only once you&#039;re sure the constants won&#039;t change anymore.&lt;br /&gt;
&lt;br /&gt;
* Use a local to save the value of a repeated computation, when doing so will save tokens. (The more complex the computation and the more it is repeated, the more likely that a local will save tokens)   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a+1); g(a+1); h(a+1)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ap1=a+1; f(ap1); g(ap1); h(ap1)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a.x, a.x+1, a.x+5, a.x+10, a.x+12); g(a.x, -a.x)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ax=a.x; f(ax, ax+1, ax+5, ax+10, ax+12); g(ax, -ax)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For constant tables of numbers or strings, you can use a string literal with &amp;lt;code&amp;gt;split()&amp;lt;/code&amp;gt; to save many tokens.  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;t={1,2,3,10,9,8,99,-1}&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;t=split &amp;quot;1,2,3,10,9,8,99,-1&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; when possible:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;if (f()) a=x else a=y&amp;lt;/code&amp;gt; →  &amp;lt;code&amp;gt;a = f() and x or y&amp;lt;/code&amp;gt; (Beware: only works if x can never be false or nil!)&lt;br /&gt;
&lt;br /&gt;
* Prefer member access over array indexing:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;tbl[&#039;special&#039;]&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;tbl.special&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;An object like &amp;lt;code&amp;gt;{a=1,b=2,c=3}&amp;lt;/code&amp;gt; takes fewer tokens to read/write values from that &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt;, though the latter takes fewer tokens to construct. This is usually beneficial as objects usually need to be accessed in multiple places but only need to be constructed in one function.&lt;br /&gt;
&lt;br /&gt;
Miscallenous token saving tips for specific situations:&lt;br /&gt;
&lt;br /&gt;
* You can save 1 token by converting &amp;lt;code&amp;gt;pairs(mytable)&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;next, mytable&amp;lt;/code&amp;gt; (which is equivalent, with the minor exception that pairs calls the &amp;lt;code&amp;gt;__pairs&amp;lt;/code&amp;gt; metamethod if you implemented one)&lt;br /&gt;
[[Category:Research]]&lt;/div&gt;</summary>
		<author><name>107.204.125.41</name></author>
	</entry>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Tokens&amp;diff=12108</id>
		<title>Tokens</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Tokens&amp;diff=12108"/>
		<updated>2022-06-12T19:52:19Z</updated>

		<summary type="html">&lt;p&gt;107.204.125.41: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the stricter limits PICO-8 places on its carts&#039; code is that they must contain no more than 8192 tokens.&lt;br /&gt;
&lt;br /&gt;
A token is one of:&lt;br /&gt;
&lt;br /&gt;
* A literal value, such as &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, any number (e.g. &amp;lt;code&amp;gt;123&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;0xff.ff&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;-3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;~1e4&amp;lt;/code&amp;gt;), or any string (of any size).&lt;br /&gt;
* A variable or operator&lt;br /&gt;
* An opening bracket (&#039;(&#039;, &#039;[&#039;, &#039;{&#039;)&lt;br /&gt;
* A keyword, with the exception of &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In particular, the following are not counted as tokens:&lt;br /&gt;
&lt;br /&gt;
* The comma (,), semicolon (;), period (.), colon (:), and double-colon (::)&lt;br /&gt;
* Closing brackets (&#039;)&#039;, &#039;]&#039;, &#039;}&#039;)&lt;br /&gt;
* The &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;local&amp;lt;/code&amp;gt; keywords&lt;br /&gt;
* The unary minus (-) and complement (~) operators when applied on a numeric literal&lt;br /&gt;
&lt;br /&gt;
== Token saving tips ==&lt;br /&gt;
Common token saving tips that apply to most situations:&lt;br /&gt;
&lt;br /&gt;
* Instead of assigning one variable per statement, combine assignments into a single statement, saving on the &#039;=&#039; token: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;a=1 b=2 c=3&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;a,b,c = 1,2,3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a=1; local b=2&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = 1,2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can omit trailing nils when assigning variables: &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3,nil,nil&amp;lt;/code&amp;gt; -&amp;gt; &amp;lt;code&amp;gt;mynum,myobj,myobj2 = 3&amp;lt;/code&amp;gt;  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = nil,nil&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b&amp;lt;/code&amp;gt;You can also omit the declaration entirely and it will be equivalent to declaring it as nil. It is worth commenting so you do not lose track of your variables.&lt;br /&gt;
&lt;br /&gt;
* You can usually omit trailing nils when calling functions:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,nil,nil)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt; &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that some functions do check the number of arguments provided, and differ in behaviour between a nil and an unprovided argument&lt;br /&gt;
&lt;br /&gt;
* When calling a function with only 1 argument, and that argument is a string or table literal, you can omit the parentheses to save a token:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(&amp;quot;smart&amp;quot;)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f &amp;quot;smart&amp;quot;&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f({1,2,3})&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f {1,2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can usually pass &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; to boolean variables and parameters, allowing you to use other tricks in this list that allow omitting nil.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a,b,false)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(a,b)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;local a,b = true, false&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local a,b = true&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that while most operators and functions operating on booleans accept &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, a small few (like direct comparison via &amp;lt;code&amp;gt;==&amp;lt;/code&amp;gt;) can still break this approach&lt;br /&gt;
&lt;br /&gt;
* When creating your own functions, move any parameters that may not need to be specified or that can have a good default value to the end of the parameter list, so that callers can usually avoid passing them.&lt;br /&gt;
&lt;br /&gt;
* Avoid defining constants or computing constants, preferring to use a single constant instead.   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;hour=60*60; f(hour); g(hour)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;f(3600); g(3600)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;Beware that this can make changing those constants harder, so you may want to do it only once you&#039;re sure the constants won&#039;t change anymore.&lt;br /&gt;
&lt;br /&gt;
* Use a local to save the value of a repeated computation, when doing so will save tokens. (The more complex the computation and the more it is repeated, the more likely that a local will save tokens)   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a+1); g(a+1); h(a+1)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ap1=a+1; f(ap1); g(ap1); h(ap1)&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;f(a.x, a.x+1, a.x+5, a.x+10, a.x+12); g(a.x, -a.x)&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;local ax=a.x; f(ax, ax+1, ax+5, ax+10, ax+12); g(ax, -ax)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For constant tables of numbers or strings, you can use a string literal with &amp;lt;code&amp;gt;split()&amp;lt;/code&amp;gt; to save many tokens.  &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;t={1,2,3,10,9,8,99,-1}&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;t=split &amp;quot;1,2,3,10,9,8,99,-1&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use &amp;lt;code&amp;gt;and&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;or&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; when possible:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;if (f()) a=x else a=y&amp;lt;/code&amp;gt; →  &amp;lt;code&amp;gt;a = f() and x or y&amp;lt;/code&amp;gt; (Beware: only works if x can never be false or nil!)&lt;br /&gt;
&lt;br /&gt;
* Prefer member access over array indexing:   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;tbl[&#039;special&#039;]&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;tbl.special&amp;lt;/code&amp;gt;    &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;An object like &amp;lt;code&amp;gt;{a=1,b=2,c=3}&amp;lt;/code&amp;gt; takes fewer tokens to read/write values from that &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt;, though the latter takes fewer tokens to construct. This is usually beneficial as objects usually need to be accessed in multiple places but only need to be constructed in one function.&lt;br /&gt;
&lt;br /&gt;
Miscallenous token saving tips for specific situations:&lt;br /&gt;
&lt;br /&gt;
* You can save 1 token by converting &amp;lt;code&amp;gt;pairs(mytable)&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;next, mytable&amp;lt;/code&amp;gt; (which is equivalent, with the minor exception that pairs calls the &amp;lt;code&amp;gt;__pairs&amp;lt;/code&amp;gt; metamethod if you implemented one)&lt;br /&gt;
[[Category:Research]]&lt;/div&gt;</summary>
		<author><name>107.204.125.41</name></author>
	</entry>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Split&amp;diff=11977</id>
		<title>Split</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Split&amp;diff=11977"/>
		<updated>2022-06-05T04:59:54Z</updated>

		<summary type="html">&lt;p&gt;107.204.125.41: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ApiReference&lt;br /&gt;
|name=split&lt;br /&gt;
|shortdesc=Split a string into a table of elements delimited by the given separator (defaults to &amp;quot;,&amp;quot;).&lt;br /&gt;
|str||The string.&lt;br /&gt;
|separator|optional|The separator (defaults to &amp;quot;,&amp;quot;).&lt;br /&gt;
|convert_numbers|optional|When convert_numbers is true, numerical tokens are stored as numbers (defaults to true).&lt;br /&gt;
}}The &amp;lt;code&amp;gt;split()&amp;lt;/code&amp;gt; function splits a string into a table of elements delimited by the given separator (defaults to &amp;quot;,&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Empty elements are stored as empty strings.&lt;br /&gt;
&lt;br /&gt;
When the separator is &amp;quot;&amp;quot;, every character is split into a separate element.&lt;br /&gt;
&lt;br /&gt;
Split can be written without the use of parenthesis.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
split(&amp;quot;1,2,3&amp;quot;) -- returns {1,2,3}&lt;br /&gt;
split(&amp;quot;one:two:3&amp;quot;,&amp;quot;:&amp;quot;,false) -- returns {&amp;quot;one&amp;quot;,&amp;quot;two&amp;quot;,&amp;quot;3&amp;quot;}&lt;br /&gt;
split(&amp;quot;1,,2,&amp;quot;) -- returns {1,&amp;quot;&amp;quot;,2,&amp;quot;&amp;quot;}&lt;br /&gt;
split &amp;quot;1,2,3&amp;quot; --returns {1,2,3}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Lua]]&lt;br /&gt;
* [[Tables]]&lt;br /&gt;
[[Category:Reference]]&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>107.204.125.41</name></author>
	</entry>
</feed>