Skip to content

Commit c867ee2

Browse files
author
Documenter.jl
committed
build based on 0028d33
1 parent 765649a commit c867ee2

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"documenter":{"julia_version":"1.11.4","generation_timestamp":"2025-04-08T14:57:29","documenter_version":"1.10.1"}}
1+
{"documenter":{"julia_version":"1.11.5","generation_timestamp":"2025-04-15T12:01:39","documenter_version":"1.10.1"}}

previews/PR179/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
julia> consume(t3)
2020
2</code></pre><p>Moreover, advancing the state of the copy has not advanced the state of the original, because they are completely independent copies:</p><pre><code class="language-julia-repl hljs">julia&gt; consume(t2)
21-
2</code></pre><p><strong>Scoped Values</strong></p><p>It is often desirable to permit a copy of a task and the original to differ in very specific ways. For example, in the context of Sequential Monte Carlo, you might want the only difference between two copies to be their random number generator.</p><p>A generic mechanism is available to achieve this. <a href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a> and <a href="#Libtask.set_dynamic_scope!"><code>Libtask.set_dynamic_scope!</code></a> let you set and retrieve a variable which is specific to a given <a href="#Libtask.TapedTask"><code>Libtask.TapedTask</code></a>. The former can be called inside a function:</p><pre><code class="language-julia-repl hljs">julia&gt; function f()
22-
produce(get_dynamic_scope())
23-
produce(get_dynamic_scope())
21+
2</code></pre><p><strong>TapedTask-Specific Globals</strong></p><p>It is often desirable to permit a copy of a task and the original to differ in very specific ways. For example, in the context of Sequential Monte Carlo, you might want the only difference between two copies to be their random number generator.</p><p>A generic mechanism is available to achieve this. <a href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a> and <a href="#Libtask.set_dynamic_scope!"><code>Libtask.set_dynamic_scope!</code></a> let you set and retrieve a variable which is specific to a given <a href="#Libtask.TapedTask"><code>Libtask.TapedTask</code></a>. The former can be called inside a function:</p><pre><code class="language-julia-repl hljs">julia&gt; function f()
22+
produce(get_dynamic_scope(Int))
23+
produce(get_dynamic_scope(Int))
2424
return nothing
2525
end
2626
f (generic function with 1 method)</code></pre><p>The first argument to <a href="#Libtask.TapedTask"><code>Libtask.TapedTask</code></a> is the value that <a href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a> will return:</p><pre><code class="language-julia-repl hljs">julia&gt; t = TapedTask(1, f);
@@ -29,4 +29,4 @@
2929
1</code></pre><p>The value that it returns can be changed between <a href="#Libtask.consume"><code>Libtask.consume</code></a> calls:</p><pre><code class="language-julia-repl hljs">julia&gt; set_dynamic_scope!(t, 2)
3030

3131
julia&gt; consume(t)
32-
2</code></pre><p><code>Int</code>s have been used here, but it is permissible to set the value returned by <a href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a> to anything you like.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/a1eea26646f3fc3e9ffb4096978abbfdaf681481/src/copyable_task.jl#L49-L164">source</a></section></article><p>The functions discussed the above docstring (in addition to <a href="#Libtask.TapedTask"><code>TapedTask</code></a> itself) form the public interface of Libtask.jl. They divide neatly into two kinds of functions: those which are used to manipulate <a href="#Libtask.TapedTask"><code>TapedTask</code></a>s, and those which are intended to be used <em>inside</em> a <a href="#Libtask.TapedTask"><code>TapedTask</code></a>. First, manipulation of <a href="#Libtask.TapedTask"><code>TapedTask</code></a>s:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.consume" href="#Libtask.consume"><code>Libtask.consume</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">consume(t::TapedTask)</code></pre><p>Run <code>t</code> until it makes a call to <code>produce</code>. If this is the first time that <code>t</code> has been called, it start execution from the entry point. If <code>consume</code> has previously been called on <code>t</code>, it will resume from the last <code>produce</code> call. If there are no more <code>produce</code> calls, <code>nothing</code> will be returned.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/a1eea26646f3fc3e9ffb4096978abbfdaf681481/src/copyable_task.jl#L194-L201">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Base.copy-Tuple{TapedTask}" href="#Base.copy-Tuple{TapedTask}"><code>Base.copy</code></a><span class="docstring-category">Method</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">Base.copy(t::TapedTask)</code></pre><p>Makes a completely independent copy of <code>t</code>. <code>consume</code> can be applied to either the copy of <code>t</code> or the original without advancing the state of the other.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/a1eea26646f3fc3e9ffb4096978abbfdaf681481/src/copyable_task.jl#L186-L191">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.set_dynamic_scope!" href="#Libtask.set_dynamic_scope!"><code>Libtask.set_dynamic_scope!</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">set_dynamic_scope!(t::TapedTask, new_dynamic_scope)::Nothing</code></pre><p>Set the <code>dynamic_scope</code> of <code>t</code> to <code>new_dynamic_scope</code>. Any references to <code>LibTask.dynamic_scope</code> in future calls to <code>consume(t)</code> (either directly, or implicitly via iteration) will see this new value.</p><p>See also: <a href="#Libtask.get_dynamic_scope"><code>get_dynamic_scope</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/a1eea26646f3fc3e9ffb4096978abbfdaf681481/src/copyable_task.jl#L172-L180">source</a></section></article><p>Functions for use inside a <a href="#Libtask.TapedTask"><code>TapedTask</code></a>s are:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.produce" href="#Libtask.produce"><code>Libtask.produce</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">produce(x)</code></pre><p>When run inside a <a href="#Libtask.TapedTask"><code>TapedTask</code></a>, will immediately yield to the caller, producing value <code>x</code>.</p><p>See also: <a href="#Libtask.consume"><code>Libtask.consume</code></a></p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/a1eea26646f3fc3e9ffb4096978abbfdaf681481/src/copyable_task.jl#L15-L22">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.get_dynamic_scope" href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">get_dynamic_scope()</code></pre><p>Returns the dynamic scope associated to <code>Libtask</code>. If called from inside a <code>TapedTask</code>, this will return whatever is contained in its <code>dynamic_scope</code> field.</p><p>See also <a href="#Libtask.set_dynamic_scope!"><code>set_dynamic_scope!</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/a1eea26646f3fc3e9ffb4096978abbfdaf681481/src/copyable_task.jl#L3-L10">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="internals/">Internals »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.10.1 on <span class="colophon-date" title="Tuesday 8 April 2025 14:57">Tuesday 8 April 2025</span>. Using Julia version 1.11.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
32+
2</code></pre><p><code>Int</code>s have been used here, but it is permissible to set the value returned by <a href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a> to anything you like.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/0028d3357130ad75ed26943f1c1be986a4ac1e89/src/copyable_task.jl#L70-L185">source</a></section></article><p>The functions discussed the above docstring (in addition to <a href="#Libtask.TapedTask"><code>TapedTask</code></a> itself) form the public interface of Libtask.jl. They divide neatly into two kinds of functions: those which are used to manipulate <a href="#Libtask.TapedTask"><code>TapedTask</code></a>s, and those which are intended to be used <em>inside</em> a <a href="#Libtask.TapedTask"><code>TapedTask</code></a>. First, manipulation of <a href="#Libtask.TapedTask"><code>TapedTask</code></a>s:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.consume" href="#Libtask.consume"><code>Libtask.consume</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">consume(t::TapedTask)</code></pre><p>Run <code>t</code> until it makes a call to <code>produce</code>. If this is the first time that <code>t</code> has been called, it start execution from the entry point. If <code>consume</code> has previously been called on <code>t</code>, it will resume from the last <code>produce</code> call. If there are no more <code>produce</code> calls, <code>nothing</code> will be returned.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/0028d3357130ad75ed26943f1c1be986a4ac1e89/src/copyable_task.jl#L230-L237">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Base.copy-Tuple{TapedTask}" href="#Base.copy-Tuple{TapedTask}"><code>Base.copy</code></a><span class="docstring-category">Method</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">Base.copy(t::TapedTask)</code></pre><p>Makes a completely independent copy of <code>t</code>. <code>consume</code> can be applied to either the copy of <code>t</code> or the original without advancing the state of the other.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/0028d3357130ad75ed26943f1c1be986a4ac1e89/src/copyable_task.jl#L222-L227">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.set_dynamic_scope!" href="#Libtask.set_dynamic_scope!"><code>Libtask.set_dynamic_scope!</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">set_dynamic_scope!(t::TapedTask, new_dynamic_scope)::Nothing</code></pre><p>Set the <code>dynamic_scope</code> of <code>t</code> to <code>new_dynamic_scope</code>. Any references to <code>LibTask.dynamic_scope</code> in future calls to <code>consume(t)</code> (either directly, or implicitly via iteration) will see this new value.</p><p>See also: <a href="#Libtask.get_dynamic_scope"><code>get_dynamic_scope</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/0028d3357130ad75ed26943f1c1be986a4ac1e89/src/copyable_task.jl#L208-L216">source</a></section></article><p>Functions for use inside a <a href="#Libtask.TapedTask"><code>TapedTask</code></a>s are:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.produce" href="#Libtask.produce"><code>Libtask.produce</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">produce(x)</code></pre><p>When run inside a <a href="#Libtask.TapedTask"><code>TapedTask</code></a>, will immediately yield to the caller, producing value <code>x</code>.</p><p>See also: <a href="#Libtask.consume"><code>Libtask.consume</code></a></p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/0028d3357130ad75ed26943f1c1be986a4ac1e89/src/copyable_task.jl#L17-L24">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Libtask.get_dynamic_scope" href="#Libtask.get_dynamic_scope"><code>Libtask.get_dynamic_scope</code></a><span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">get_dynamic_scope(T::Type)</code></pre><p>Returns the dynamic scope associated to <code>Libtask</code>. If called from inside a <code>TapedTask</code>, this will return whatever is contained in its <code>dynamic_scope</code> field.</p><p>The type <code>T</code> is required for optimal performance. If you know that the result of this operation must return a specific type, specific <code>T</code>. If you do not know what type it will return, pass <code>Any</code> – this will typically yield type instabilities, but will run correctly.</p><p>See also <a href="#Libtask.set_dynamic_scope!"><code>set_dynamic_scope!</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/Libtask.jl/blob/0028d3357130ad75ed26943f1c1be986a4ac1e89/src/copyable_task.jl#L1-L12">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="internals/">Internals »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.10.1 on <span class="colophon-date" title="Tuesday 15 April 2025 12:01">Tuesday 15 April 2025</span>. Using Julia version 1.11.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>

0 commit comments

Comments
 (0)