Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
deploy: c453c90
Browse files Browse the repository at this point in the history
  • Loading branch information
sblackshear committed May 4, 2024
1 parent 462ae2c commit 95f07e7
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 88 deletions.
10 changes: 5 additions & 5 deletions abilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ <h2 id="conditional-abilities-and-generic-types"><a class="header" href="#condit
</ul>
<p>Here are examples for this conditional system for each ability:</p>
<h3 id="example-conditional-copy"><a class="header" href="#example-conditional-copy">Example: conditional <code>copy</code></a></h3>
<pre><code>struct NoAbilities {}
<pre><code class="language-move">struct NoAbilities {}
struct S has copy, drop { f: bool }
struct Cup&lt;T&gt; has copy, drop, store { item: T }

Expand All @@ -292,7 +292,7 @@ <h3 id="example-conditional-copy"><a class="header" href="#example-conditional-c
}
</code></pre>
<h3 id="example-conditional-drop"><a class="header" href="#example-conditional-drop">Example: conditional <code>drop</code></a></h3>
<pre><code>struct NoAbilities {}
<pre><code class="language-move">struct NoAbilities {}
struct S has copy, drop { f: bool }
struct Cup&lt;T&gt; has copy, drop, store { item: T }

Expand All @@ -318,13 +318,13 @@ <h3 id="example-conditional-drop"><a class="header" href="#example-conditional-d

fun invalid_left_in_local(): u64 {
let n = Cup&lt;NoAbilities&gt; { item: NoAbilities {}};
// Invalid return: 'c_n' has a value
// Invalid return: 'n' has a value
// and 'Cup&lt;NoAbilities&gt;' does not have 'drop'
0
}
</code></pre>
<h3 id="example-conditional-store"><a class="header" href="#example-conditional-store">Example: conditional <code>store</code></a></h3>
<pre><code>struct Cup&lt;T&gt; has copy, drop, store { item: T }
<pre><code class="language-move">struct Cup&lt;T&gt; has copy, drop, store { item: T }

// 'MyInnerResource' is declared with 'store' so all fields need 'store'
struct MyInnerResource has store {
Expand All @@ -340,7 +340,7 @@ <h3 id="example-conditional-store"><a class="header" href="#example-conditional-
}
</code></pre>
<h3 id="example-conditional-key"><a class="header" href="#example-conditional-key">Example: conditional <code>key</code></a></h3>
<pre><code>struct NoAbilities {}
<pre><code class="language-move">struct NoAbilities {}
struct MyResource&lt;T&gt; has key { f: T }

fun valid(account: &amp;signer) acquires MyResource {
Expand Down
2 changes: 1 addition & 1 deletion coding-conventions.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h2 id="naming"><a class="header" href="#naming">Naming</a></h2>
<li><strong>Constant names</strong>: should be upper camel case and begin with an <code>E</code> if they represent error codes (e.g., <code>EIndexOutOfBounds</code>) and upper snake case if they represent a non-error value (e.g., <code>MIN_STAKE</code>).</li>
<li></li>
<li><strong>Generic type names</strong>: should be descriptive, or anti-descriptive where appropriate, e.g., <code>T</code> or <code>Element</code> for the Vector generic type parameter. Most of the time the &quot;main&quot; type in a module should be the same name as the module e.g., <code>option::Option</code>, <code>fixed_point32::FixedPoint32</code>.</li>
<li><strong>Module file names</strong>: should be the same as the module name e.g., <code>option.move</code>.</li>
<li><strong>Module file names</strong>: should be the same as the module name e.g., <code>Option.move</code>.</li>
<li><strong>Script file names</strong>: should be lower snake case and should match the name of the “main” function in the script.</li>
<li><strong>Mixed file names</strong>: If the file contains multiple modules and/or scripts, the file name should be lower snake case, where the name does not match any particular module/script inside.</li>
</ul>
Expand Down
36 changes: 1 addition & 35 deletions functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ <h4 id="public-visibility"><a class="header" href="#public-visibility"><code>pub
<li>functions defined in another module, or</li>
<li>the function defined in a script.</li>
</ul>
<p>There are also no restrictions for what the argument types a public function can take and its return type.</p>
<pre><code class="language-move=">address 0x42 {
module m {
public fun foo(): u64 { 0 }
Expand Down Expand Up @@ -302,13 +301,12 @@ <h3 id="entry-modifier"><a class="header" href="#entry-modifier"><code>entry</co
}
}
</code></pre>
<p>Entry functions can take primitive types, String, and vector arguments but cannot take Structs (e.g. Option). They also
must not have any return values.</p>
<h3 id="name"><a class="header" href="#name">Name</a></h3>
<p>Function names can start with letters <code>a</code> to <code>z</code> or letters <code>A</code> to <code>Z</code>. After the first character, function names can contain underscores <code>_</code>, letters <code>a</code> to <code>z</code>, letters <code>A</code> to <code>Z</code>, or digits <code>0</code> to <code>9</code>.</p>
<pre><code class="language-move">fun FOO() {}
fun bar_42() {}
fun _bAZ19() {}
^^^^^^ Invalid function name '_bAZ19'. Function names cannot start with '_'
</code></pre>
<h3 id="type-parameters"><a class="header" href="#type-parameters">Type Parameters</a></h3>
<p>After the name, functions can have type parameters</p>
Expand Down Expand Up @@ -544,38 +542,6 @@ <h3 id="return-expression"><a class="header" href="#return-expression"><code>ret
<pre><code class="language-move">fun foo() { return }
fun foo() { return () }
</code></pre>
<h2 id="inline-functions"><a class="header" href="#inline-functions">Inline Functions</a></h2>
<p>Inline functions are functions which are expanded at caller side instead
of compiled into Move bytecode. This allows to safe gas and may lead
to faster execution. For example, one can define an inline function</p>
<pre><code class="language-move=">inline fun percent(x: u64, y: u64):u64 { x * 100 / y }
</code></pre>
<p>Now, when call <code>percent(2, 200)</code> the compiler will inline the function
definition as if the user has written <code>2 * 100 / 200</code>.</p>
<h3 id="function-parameters"><a class="header" href="#function-parameters">Function Parameters</a></h3>
<p>Inline functions support <em>function parameters</em>. This allows
to define higher-order functions in Move which can comprehend common
programming patterns. As inline functions are expanded at compilation time,
this feature of function parameters can be supported without direct
support for it in Move bytecode.</p>
<p>Consider the following function (from the <code>vector</code> module):</p>
<pre><code class="language-move=">/// Fold the function over the elements. For example, `fold(vector[1,2,3], 0, f)` will execute
/// `f(f(f(0, 1), 2), 3)`
public inline fun fold&lt;Accumulator, Element&gt;(
v: vector&lt;Element&gt;,
init: Accumulator,
f: |Accumulator,Element|Accumulator
): Accumulator {
let accu = init;
foreach(v, |elem| accu = g(accu, elem));
accu
}
</code></pre>
<p>Here, <code>foreach</code> is itself an inline function.</p>
<p>In general, only lambda expressions can be passed to function parameters.
Similar as the inline function itself, those lambdas are expanded at caller
side. Notice that a lambda can access variables in the context, as in the
example the variable <code>accu</code>.</p>

</main>

Expand Down
52 changes: 9 additions & 43 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,6 @@ <h4 id="public-visibility"><a class="header" href="#public-visibility"><code>pub
<li>functions defined in another module, or</li>
<li>the function defined in a script.</li>
</ul>
<p>There are also no restrictions for what the argument types a public function can take and its return type.</p>
<pre><code class="language-move=">address 0x42 {
module m {
public fun foo(): u64 { 0 }
Expand Down Expand Up @@ -2077,13 +2076,12 @@ <h3 id="entry-modifier"><a class="header" href="#entry-modifier"><code>entry</co
}
}
</code></pre>
<p>Entry functions can take primitive types, String, and vector arguments but cannot take Structs (e.g. Option). They also
must not have any return values.</p>
<h3 id="name"><a class="header" href="#name">Name</a></h3>
<p>Function names can start with letters <code>a</code> to <code>z</code> or letters <code>A</code> to <code>Z</code>. After the first character, function names can contain underscores <code>_</code>, letters <code>a</code> to <code>z</code>, letters <code>A</code> to <code>Z</code>, or digits <code>0</code> to <code>9</code>.</p>
<pre><code class="language-move">fun FOO() {}
fun bar_42() {}
fun _bAZ19() {}
^^^^^^ Invalid function name '_bAZ19'. Function names cannot start with '_'
</code></pre>
<h3 id="type-parameters"><a class="header" href="#type-parameters">Type Parameters</a></h3>
<p>After the name, functions can have type parameters</p>
Expand Down Expand Up @@ -2319,38 +2317,6 @@ <h3 id="return-expression"><a class="header" href="#return-expression"><code>ret
<pre><code class="language-move">fun foo() { return }
fun foo() { return () }
</code></pre>
<h2 id="inline-functions"><a class="header" href="#inline-functions">Inline Functions</a></h2>
<p>Inline functions are functions which are expanded at caller side instead
of compiled into Move bytecode. This allows to safe gas and may lead
to faster execution. For example, one can define an inline function</p>
<pre><code class="language-move=">inline fun percent(x: u64, y: u64):u64 { x * 100 / y }
</code></pre>
<p>Now, when call <code>percent(2, 200)</code> the compiler will inline the function
definition as if the user has written <code>2 * 100 / 200</code>.</p>
<h3 id="function-parameters"><a class="header" href="#function-parameters">Function Parameters</a></h3>
<p>Inline functions support <em>function parameters</em>. This allows
to define higher-order functions in Move which can comprehend common
programming patterns. As inline functions are expanded at compilation time,
this feature of function parameters can be supported without direct
support for it in Move bytecode.</p>
<p>Consider the following function (from the <code>vector</code> module):</p>
<pre><code class="language-move=">/// Fold the function over the elements. For example, `fold(vector[1,2,3], 0, f)` will execute
/// `f(f(f(0, 1), 2), 3)`
public inline fun fold&lt;Accumulator, Element&gt;(
v: vector&lt;Element&gt;,
init: Accumulator,
f: |Accumulator,Element|Accumulator
): Accumulator {
let accu = init;
foreach(v, |elem| accu = g(accu, elem));
accu
}
</code></pre>
<p>Here, <code>foreach</code> is itself an inline function.</p>
<p>In general, only lambda expressions can be passed to function parameters.
Similar as the inline function itself, those lambdas are expanded at caller
side. Notice that a lambda can access variables in the context, as in the
example the variable <code>accu</code>.</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="structs-and-resources"><a class="header" href="#structs-and-resources">Structs and Resources</a></h1>
<p>A <em>struct</em> is a user-defined data structure containing typed fields. Structs can store any
non-reference type, including other structs.</p>
Expand Down Expand Up @@ -3356,7 +3322,7 @@ <h2 id="conditional-abilities-and-generic-types"><a class="header" href="#condit
</ul>
<p>Here are examples for this conditional system for each ability:</p>
<h3 id="example-conditional-copy"><a class="header" href="#example-conditional-copy">Example: conditional <code>copy</code></a></h3>
<pre><code>struct NoAbilities {}
<pre><code class="language-move">struct NoAbilities {}
struct S has copy, drop { f: bool }
struct Cup&lt;T&gt; has copy, drop, store { item: T }

Expand All @@ -3378,7 +3344,7 @@ <h3 id="example-conditional-copy"><a class="header" href="#example-conditional-c
}
</code></pre>
<h3 id="example-conditional-drop"><a class="header" href="#example-conditional-drop">Example: conditional <code>drop</code></a></h3>
<pre><code>struct NoAbilities {}
<pre><code class="language-move">struct NoAbilities {}
struct S has copy, drop { f: bool }
struct Cup&lt;T&gt; has copy, drop, store { item: T }

Expand All @@ -3404,13 +3370,13 @@ <h3 id="example-conditional-drop"><a class="header" href="#example-conditional-d

fun invalid_left_in_local(): u64 {
let n = Cup&lt;NoAbilities&gt; { item: NoAbilities {}};
// Invalid return: 'c_n' has a value
// Invalid return: 'n' has a value
// and 'Cup&lt;NoAbilities&gt;' does not have 'drop'
0
}
</code></pre>
<h3 id="example-conditional-store"><a class="header" href="#example-conditional-store">Example: conditional <code>store</code></a></h3>
<pre><code>struct Cup&lt;T&gt; has copy, drop, store { item: T }
<pre><code class="language-move">struct Cup&lt;T&gt; has copy, drop, store { item: T }

// 'MyInnerResource' is declared with 'store' so all fields need 'store'
struct MyInnerResource has store {
Expand All @@ -3426,7 +3392,7 @@ <h3 id="example-conditional-store"><a class="header" href="#example-conditional-
}
</code></pre>
<h3 id="example-conditional-key"><a class="header" href="#example-conditional-key">Example: conditional <code>key</code></a></h3>
<pre><code>struct NoAbilities {}
<pre><code class="language-move">struct NoAbilities {}
struct MyResource&lt;T&gt; has key { f: T }

fun valid(account: &amp;signer) acquires MyResource {
Expand Down Expand Up @@ -4178,7 +4144,7 @@ <h2 id="running-unit-tests"><a class="header" href="#running-unit-tests">Running
command</a>.</p>
<p>When running tests, every test will either <code>PASS</code>, <code>FAIL</code>, or <code>TIMEOUT</code>. If a test case fails, the location of the failure along with the function name that caused the failure will be reported if possible. You can see an example of this below.</p>
<p>A test will be marked as timing out if it exceeds the maximum number of instructions that can be executed for any single test. This bound can be changed using the options below, and its default value is set to 5000 instructions. Additionally, while the result of a test is always deterministic, tests are run in parallel by default, so the ordering of test results in a test run is non-deterministic unless running with only one thread (see <code>OPTIONS</code> below).</p>
<p>There are also a number of options that can be passed to the unit testing binary to fine-tune testing and to help debug failing tests. These can be found using the help flag:</p>
<p>There are also a number of options that can be passed to the unit testing binary to fine-tune testing and to help debug failing tests. These can be found using the the help flag:</p>
<pre><code>$ move -h
</code></pre>
<h2 id="example-1"><a class="header" href="#example-1">Example</a></h2>
Expand Down Expand Up @@ -4772,7 +4738,7 @@ <h3 id="constants-1"><a class="header" href="#constants-1">Constants</a></h3>
<pre><code class="language-move"> const INVALID_STATE: u8 = 1;
</code></pre>
<hr />
<p>A specific account address was required to perform an operation, but a different address from what was expected was encountered.</p>
<p>A specific account address was required to perform an operation, but a different address from what was expected was encounterd.</p>
<pre><code class="language-move"> const REQUIRES_ADDRESS: u8 = 2;
</code></pre>
<hr />
Expand Down Expand Up @@ -4890,7 +4856,7 @@ <h2 id="naming-2"><a class="header" href="#naming-2">Naming</a></h2>
<li><strong>Constant names</strong>: should be upper camel case and begin with an <code>E</code> if they represent error codes (e.g., <code>EIndexOutOfBounds</code>) and upper snake case if they represent a non-error value (e.g., <code>MIN_STAKE</code>).</li>
<li></li>
<li><strong>Generic type names</strong>: should be descriptive, or anti-descriptive where appropriate, e.g., <code>T</code> or <code>Element</code> for the Vector generic type parameter. Most of the time the &quot;main&quot; type in a module should be the same name as the module e.g., <code>option::Option</code>, <code>fixed_point32::FixedPoint32</code>.</li>
<li><strong>Module file names</strong>: should be the same as the module name e.g., <code>option.move</code>.</li>
<li><strong>Module file names</strong>: should be the same as the module name e.g., <code>Option.move</code>.</li>
<li><strong>Script file names</strong>: should be lower snake case and should match the name of the “main” function in the script.</li>
<li><strong>Mixed file names</strong>: If the file contains multiple modules and/or scripts, the file name should be lower snake case, where the name does not match any particular module/script inside.</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion standard-library.html
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ <h3 id="constants"><a class="header" href="#constants">Constants</a></h3>
<pre><code class="language-move"> const INVALID_STATE: u8 = 1;
</code></pre>
<hr />
<p>A specific account address was required to perform an operation, but a different address from what was expected was encountered.</p>
<p>A specific account address was required to perform an operation, but a different address from what was expected was encounterd.</p>
<pre><code class="language-move"> const REQUIRES_ADDRESS: u8 = 2;
</code></pre>
<hr />
Expand Down
2 changes: 1 addition & 1 deletion unit-testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ <h2 id="running-unit-tests"><a class="header" href="#running-unit-tests">Running
command</a>.</p>
<p>When running tests, every test will either <code>PASS</code>, <code>FAIL</code>, or <code>TIMEOUT</code>. If a test case fails, the location of the failure along with the function name that caused the failure will be reported if possible. You can see an example of this below.</p>
<p>A test will be marked as timing out if it exceeds the maximum number of instructions that can be executed for any single test. This bound can be changed using the options below, and its default value is set to 5000 instructions. Additionally, while the result of a test is always deterministic, tests are run in parallel by default, so the ordering of test results in a test run is non-deterministic unless running with only one thread (see <code>OPTIONS</code> below).</p>
<p>There are also a number of options that can be passed to the unit testing binary to fine-tune testing and to help debug failing tests. These can be found using the help flag:</p>
<p>There are also a number of options that can be passed to the unit testing binary to fine-tune testing and to help debug failing tests. These can be found using the the help flag:</p>
<pre><code>$ move -h
</code></pre>
<h2 id="example"><a class="header" href="#example">Example</a></h2>
Expand Down

0 comments on commit 95f07e7

Please sign in to comment.