411 lines
179 KiB
HTML
411 lines
179 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Essentials · The Julia Language</title><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-28835595-6', 'auto');
|
|
ga('send', 'pageview');
|
|
</script><link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css" rel="stylesheet" type="text/css"/><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link href="../assets/documenter.css" rel="stylesheet" type="text/css"/><link href="../assets/julia-manual.css" rel="stylesheet" type="text/css"/></head><body><nav class="toc"><a href="../index.html"><img class="logo" src="../assets/logo.png" alt="The Julia Language logo"/></a><h1>The Julia Language</h1><select id="version-selector" onChange="window.location.href=this.value" style="visibility: hidden"></select><form class="search" id="search-form" action="../search.html"><input id="search-query" name="q" type="text" placeholder="Search docs"/></form><ul><li><a class="toctext" href="../index.html">Home</a></li><li><span class="toctext">Manual</span><ul><li><a class="toctext" href="../manual/introduction.html">Introduction</a></li><li><a class="toctext" href="../manual/getting-started.html">Getting Started</a></li><li><a class="toctext" href="../manual/variables.html">Variables</a></li><li><a class="toctext" href="../manual/integers-and-floating-point-numbers.html">Integers and Floating-Point Numbers</a></li><li><a class="toctext" href="../manual/mathematical-operations.html">Mathematical Operations and Elementary Functions</a></li><li><a class="toctext" href="../manual/complex-and-rational-numbers.html">Complex and Rational Numbers</a></li><li><a class="toctext" href="../manual/strings.html">Strings</a></li><li><a class="toctext" href="../manual/functions.html">Functions</a></li><li><a class="toctext" href="../manual/control-flow.html">Control Flow</a></li><li><a class="toctext" href="../manual/variables-and-scoping.html">Scope of Variables</a></li><li><a class="toctext" href="../manual/types.html">Types</a></li><li><a class="toctext" href="../manual/methods.html">Methods</a></li><li><a class="toctext" href="../manual/constructors.html">Constructors</a></li><li><a class="toctext" href="../manual/conversion-and-promotion.html">Conversion and Promotion</a></li><li><a class="toctext" href="../manual/interfaces.html">Interfaces</a></li><li><a class="toctext" href="../manual/modules.html">Modules</a></li><li><a class="toctext" href="../manual/documentation.html">Documentation</a></li><li><a class="toctext" href="../manual/metaprogramming.html">Metaprogramming</a></li><li><a class="toctext" href="../manual/arrays.html">Multi-dimensional Arrays</a></li><li><a class="toctext" href="../manual/linear-algebra.html">Linear algebra</a></li><li><a class="toctext" href="../manual/networking-and-streams.html">Networking and Streams</a></li><li><a class="toctext" href="../manual/parallel-computing.html">Parallel Computing</a></li><li><a class="toctext" href="../manual/dates.html">Date and DateTime</a></li><li><a class="toctext" href="../manual/interacting-with-julia.html">Interacting With Julia</a></li><li><a class="toctext" href="../manual/running-external-programs.html">Running External Programs</a></li><li><a class="toctext" href="../manual/calling-c-and-fortran-code.html">Calling C and Fortran Code</a></li><li><a class="toctext" href="../manual/handling-operating-system-variation.html">Handling Operating System Variation</a></li><li><a class="toctext" href="../manual/environment-variables.html">Environment Variables</a></li><li><a class="toctext" href="../manual/embedding.html">Embedding Julia</a></li><li><a class="toctext" href="../manual/packages.html">Packages</a></li><li><a class="toctext" href="../manual/profile.html">Profiling</a></li><li><a class="toctext" href="../manual/stacktraces.html">Stack Traces</a></li><li><a class="toctext" href="../manual/performance-tips.html">Performance Tips</a></li><li><a class="toctext" href="../manual/workflow-tips.html">Workflow Tips</a></li><li><a class="toctext" href="../manual/style-guide.html">Style Guide</a></li><li><a class="toctext" href="../manual/faq.html">Frequently Asked Questions</a></li><li><a class="toctext" href="../manual/noteworthy-differences.html">Noteworthy Differences from other Languages</a></li><li><a class="toctext" href="../manual/unicode-input.html">Unicode Input</a></li></ul></li><li><span class="toctext">Standard Library</span><ul><li class="current"><a class="toctext" href="base.html">Essentials</a><ul class="internal"><li><a class="toctext" href="#Introduction-1">Introduction</a></li><li><a class="toctext" href="#Getting-Around-1">Getting Around</a></li><li><a class="toctext" href="#All-Objects-1">All Objects</a></li><li><a class="toctext" href="#Types-1">Types</a></li><li><a class="toctext" href="#Generic-Functions-1">Generic Functions</a></li><li><a class="toctext" href="#Syntax-1">Syntax</a></li><li><a class="toctext" href="#Nullables-1">Nullables</a></li><li><a class="toctext" href="#System-1">System</a></li><li><a class="toctext" href="#Errors-1">Errors</a></li><li><a class="toctext" href="#Events-1">Events</a></li><li><a class="toctext" href="#Reflection-1">Reflection</a></li><li><a class="toctext" href="#Internals-1">Internals</a></li></ul></li><li><a class="toctext" href="collections.html">Collections and Data Structures</a></li><li><a class="toctext" href="math.html">Mathematics</a></li><li><a class="toctext" href="numbers.html">Numbers</a></li><li><a class="toctext" href="strings.html">Strings</a></li><li><a class="toctext" href="arrays.html">Arrays</a></li><li><a class="toctext" href="parallel.html">Tasks and Parallel Computing</a></li><li><a class="toctext" href="linalg.html">Linear Algebra</a></li><li><a class="toctext" href="constants.html">Constants</a></li><li><a class="toctext" href="file.html">Filesystem</a></li><li><a class="toctext" href="io-network.html">I/O and Network</a></li><li><a class="toctext" href="punctuation.html">Punctuation</a></li><li><a class="toctext" href="sort.html">Sorting and Related Functions</a></li><li><a class="toctext" href="pkg.html">Package Manager Functions</a></li><li><a class="toctext" href="dates.html">Dates and Time</a></li><li><a class="toctext" href="iterators.html">Iteration utilities</a></li><li><a class="toctext" href="test.html">Unit Testing</a></li><li><a class="toctext" href="c.html">C Interface</a></li><li><a class="toctext" href="libc.html">C Standard Library</a></li><li><a class="toctext" href="libdl.html">Dynamic Linker</a></li><li><a class="toctext" href="profile.html">Profiling</a></li><li><a class="toctext" href="stacktraces.html">StackTraces</a></li><li><a class="toctext" href="simd-types.html">SIMD Support</a></li></ul></li><li><span class="toctext">Developer Documentation</span><ul><li><a class="toctext" href="../devdocs/reflection.html">Reflection and introspection</a></li><li><span class="toctext">Documentation of Julia's Internals</span><ul><li><a class="toctext" href="../devdocs/init.html">Initialization of the Julia runtime</a></li><li><a class="toctext" href="../devdocs/ast.html">Julia ASTs</a></li><li><a class="toctext" href="../devdocs/types.html">More about types</a></li><li><a class="toctext" href="../devdocs/object.html">Memory layout of Julia Objects</a></li><li><a class="toctext" href="../devdocs/eval.html">Eval of Julia code</a></li><li><a class="toctext" href="../devdocs/callconv.html">Calling Conventions</a></li><li><a class="toctext" href="../devdocs/compiler.html">High-level Overview of the Native-Code Generation Process</a></li><li><a class="toctext" href="../devdocs/functions.html">Julia Functions</a></li><li><a class="toctext" href="../devdocs/cartesian.html">Base.Cartesian</a></li><li><a class="toctext" href="../devdocs/meta.html">Talking to the compiler (the <code>:meta</code> mechanism)</a></li><li><a class="toctext" href="../devdocs/subarrays.html">SubArrays</a></li><li><a class="toctext" href="../devdocs/sysimg.html">System Image Building</a></li><li><a class="toctext" href="../devdocs/llvm.html">Working with LLVM</a></li><li><a class="toctext" href="../devdocs/stdio.html">printf() and stdio in the Julia runtime</a></li><li><a class="toctext" href="../devdocs/boundscheck.html">Bounds checking</a></li><li><a class="toctext" href="../devdocs/locks.html">Proper maintenance and care of multi-threading locks</a></li><li><a class="toctext" href="../devdocs/offset-arrays.html">Arrays with custom indices</a></li><li><a class="toctext" href="../devdocs/libgit2.html">Base.LibGit2</a></li><li><a class="toctext" href="../devdocs/require.html">Module loading</a></li></ul></li><li><span class="toctext">Developing/debugging Julia's C code</span><ul><li><a class="toctext" href="../devdocs/backtraces.html">Reporting and analyzing crashes (segfaults)</a></li><li><a class="toctext" href="../devdocs/debuggingtips.html">gdb debugging tips</a></li><li><a class="toctext" href="../devdocs/valgrind.html">Using Valgrind with Julia</a></li><li><a class="toctext" href="../devdocs/sanitizers.html">Sanitizer support</a></li></ul></li></ul></li></ul></nav><article id="docs"><header><nav><ul><li>Standard Library</li><li><a href="base.html">Essentials</a></li></ul><a class="edit-page" href="https://github.com/JuliaLang/julia/blob/master/doc/src/stdlib/base.md"><span class="fa"></span> Edit on GitHub</a></nav><hr/><div id="topbar"><span>Essentials</span><a class="fa fa-bars" href="#"></a></div></header><h1><a class="nav-anchor" id="Essentials-1" href="#Essentials-1">Essentials</a></h1><h2><a class="nav-anchor" id="Introduction-1" href="#Introduction-1">Introduction</a></h2><p>The Julia standard library contains a range of functions and macros appropriate for performing scientific and numerical computing, but is also as broad as those of many general purpose programming languages. Additional functionality is available from a growing collection of available packages. Functions are grouped by topic below.</p><p>Some general notes:</p><ul><li><p>Except for functions in built-in modules (<code>Pkg</code>, <code>Collections</code>, <code>Test</code> and <code>Profile</code>), all functions documented here are directly available for use in programs.</p></li><li><p>To use module functions, use <code>import Module</code> to import the module, and <code>Module.fn(x)</code> to use the functions.</p></li><li><p>Alternatively, <code>using Module</code> will import all exported <code>Module</code> functions into the current namespace.</p></li><li><p>By convention, function names ending with an exclamation point (<code>!</code>) modify their arguments. Some functions have both modifying (e.g., <code>sort!</code>) and non-modifying (<code>sort</code>) versions.</p></li></ul><h2><a class="nav-anchor" id="Getting-Around-1" href="#Getting-Around-1">Getting Around</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.exit" href="#Base.exit"><code>Base.exit</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">exit([code])</code></pre><p>Quit (or control-D at the prompt). The default exit code is zero, indicating that the processes completed successfully.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2486-L2491">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.quit" href="#Base.quit"><code>Base.quit</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">quit()</code></pre><p>Quit the program indicating that the processes completed successfully. This function calls <code>exit(0)</code> (see <a href="base.html#Base.exit"><code>exit</code></a>).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1381-L1386">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.atexit" href="#Base.atexit"><code>Base.atexit</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">atexit(f)</code></pre><p>Register a zero-argument function <code>f()</code> to be called at process exit. <code>atexit()</code> hooks are called in last in first out (LIFO) order and run before object finalizers.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1569-L1574">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.atreplinit" href="#Base.atreplinit"><code>Base.atreplinit</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">atreplinit(f)</code></pre><p>Register a one-argument function to be called before the REPL interface is initialized in interactive sessions; this is useful to customize the interface. The argument of <code>f</code> is the REPL object. This function should be called from within the <code>.juliarc.jl</code> initialization file.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/client.jl#L344-L351">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isinteractive" href="#Base.isinteractive"><code>Base.isinteractive</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isinteractive() -> Bool</code></pre><p>Determine whether Julia is running an interactive session.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L537-L541">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.whos" href="#Base.whos"><code>Base.whos</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">whos(io::IO=STDOUT, m::Module=current_module(), pattern::Regex=r"")</code></pre><p>Print information about exported global variables in a module, optionally restricted to those matching <code>pattern</code>.</p><p>The memory consumption estimate is an approximate lower bound on the size of the internal structure of the object.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L718-L724">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.summarysize" href="#Base.summarysize"><code>Base.summarysize</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Base.summarysize(obj; exclude=Union{...}, chargeall=Union{...}) -> Int</code></pre><p>Compute the amount of memory used by all unique objects reachable from the argument.</p><p><strong>Keyword Arguments</strong></p><ul><li><p><code>exclude</code>: specifies the types of objects to exclude from the traversal.</p></li><li><p><code>chargeall</code>: specifies the types of objects to always charge the size of all of their fields, even if those fields would normally be excluded.</p></li></ul></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/summarysize.jl#L12-L21">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.edit-Tuple{AbstractString,Integer}" href="#Base.edit-Tuple{AbstractString,Integer}"><code>Base.edit</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">edit(path::AbstractString, line::Integer=0)</code></pre><p>Edit a file or directory optionally providing a line number to edit the file at. Returns to the <code>julia</code> prompt when you quit the editor. The editor can be changed by setting <code>JULIA_EDITOR</code>, <code>VISUAL</code> or <code>EDITOR</code> as an environment variable.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L26-L32">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.edit-Tuple{Any}" href="#Base.edit-Tuple{Any}"><code>Base.edit</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">edit(function, [types])</code></pre><p>Edit the definition of a function, optionally specifying a tuple of types to indicate which method to edit. The editor can be changed by setting <code>JULIA_EDITOR</code>, <code>VISUAL</code> or <code>EDITOR</code> as an environment variable.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L80-L86">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@edit" href="#Base.@edit"><code>Base.@edit</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@edit</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls the <code>edit</code> function on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L488-L493">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.less-Tuple{AbstractString}" href="#Base.less-Tuple{AbstractString}"><code>Base.less</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">less(file::AbstractString, [line::Integer])</code></pre><p>Show a file using the default pager, optionally providing a starting line number. Returns to the <code>julia</code> prompt when you quit the pager.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L106-L111">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.less-Tuple{Any}" href="#Base.less-Tuple{Any}"><code>Base.less</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">less(function, [types])</code></pre><p>Show the definition of a function using the default pager, optionally specifying a tuple of types to indicate which method to see.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L114-L119">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@less" href="#Base.@less"><code>Base.@less</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@less</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls the <code>less</code> function on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L480-L485">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.clipboard-Tuple{Any}" href="#Base.clipboard-Tuple{Any}"><code>Base.clipboard</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">clipboard(x)</code></pre><p>Send a printed form of <code>x</code> to the operating system clipboard ("copy").</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L222-L226">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.clipboard-Tuple{}" href="#Base.clipboard-Tuple{}"><code>Base.clipboard</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">clipboard() -> AbstractString</code></pre><p>Return a string with the contents of the operating system clipboard ("paste").</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L229-L233">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.reload" href="#Base.reload"><code>Base.reload</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">reload(name::AbstractString)</code></pre><p>Force reloading of a package, even if it has been loaded before. This is intended for use during package development as code is modified.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L366-L371">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.require" href="#Base.require"><code>Base.require</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">require(module::Symbol)</code></pre><p>This function is part of the implementation of <code>using</code> / <code>import</code>, if a module is not already defined in <code>Main</code>. It can also be called directly to force reloading a module, regardless of whether it has been loaded before (for example, when interactively developing libraries).</p><p>Loads a source file, in the context of the <code>Main</code> module, on every active node, searching standard locations for files. <code>require</code> is considered a top-level operation, so it sets the current <code>include</code> path but does not use it to search for files (see help for <code>include</code>). This function is typically used to load library code, and is implicitly called by <code>using</code> to load packages.</p><p>When searching for files, <code>require</code> first looks for package code under <code>Pkg.dir()</code>, then tries paths in the global array <code>LOAD_PATH</code>. <code>require</code> is case-sensitive on all platforms, including those with case-insensitive filesystems like macOS and Windows.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L385-L403">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.compilecache" href="#Base.compilecache"><code>Base.compilecache</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Base.compilecache(module::String)</code></pre><p>Creates a precompiled cache file for a module and all of its dependencies. This can be used to reduce package load times. Cache files are stored in <code>LOAD_CACHE_PATH[1]</code>, which defaults to <code>~/.julia/lib/VERSION</code>. See <a href="../manual/modules.html#Module-initialization-and-precompilation-1">Module initialization and precompilation</a> for important notes.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L666-L675">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.__precompile__" href="#Base.__precompile__"><code>Base.__precompile__</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">__precompile__(isprecompilable::Bool=true)</code></pre><p>Specify whether the file calling this function is precompilable. If <code>isprecompilable</code> is <code>true</code>, then <code>__precompile__</code> throws an exception when the file is loaded by <code>using</code>/<code>import</code>/<code>require</code> <em>unless</em> the file is being precompiled, and in a module file it causes the module to be automatically precompiled when it is imported. Typically, <code>__precompile__()</code> should occur before the <code>module</code> declaration in the file, or better yet <code>VERSION >= v"0.4" && __precompile__()</code> in order to be backward-compatible with Julia 0.3.</p><p>If a module or file is <em>not</em> safely precompilable, it should call <code>__precompile__(false)</code> in order to throw an error if Julia attempts to precompile it.</p><p><code>__precompile__()</code> should <em>not</em> be used in a module unless all of its dependencies are also using <code>__precompile__()</code>. Failure to do so can result in a runtime error when loading the module.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L321-L336">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.include" href="#Base.include"><code>Base.include</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">include(path::AbstractString)</code></pre><p>Evaluate the contents of the input source file in the current context. Returns the result of the last evaluated expression of the input file. During including, a task-local include path is set to the directory containing the file. Nested calls to <code>include</code> will search relative to that path. All paths refer to files on node 1 when running in parallel, and files will be fetched from node 1. This function is typically used to load source interactively, or to combine files in packages that are broken into multiple source files.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L591-L600">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.include_string" href="#Base.include_string"><code>Base.include_string</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">include_string(code::AbstractString, filename::AbstractString="string")</code></pre><p>Like <code>include</code>, except reads code from the given string rather than from a file. Since there is no file path involved, no path processing or fetching from node 1 is done.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L516-L521">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.include_dependency" href="#Base.include_dependency"><code>Base.include_dependency</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">include_dependency(path::AbstractString)</code></pre><p>In a module, declare that the file specified by <code>path</code> (relative or absolute) is a dependency for precompilation; that is, the module will need to be recompiled if this file changes.</p><p>This is only needed if your module depends on a file that is not used via <code>include</code>. It has no effect outside of compilation.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L287-L296">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Docs.apropos" href="#Base.Docs.apropos"><code>Base.Docs.apropos</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">apropos(string)</code></pre><p>Search through all documentation for a string, ignoring case.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/utils.jl#L440-L444">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.which-Tuple{Any,Any}" href="#Base.which-Tuple{Any,Any}"><code>Base.which</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">which(f, types)</code></pre><p>Returns the method of <code>f</code> (a <code>Method</code> object) that would be called for arguments of the given <code>types</code>.</p><p>If <code>types</code> is an abstract type, then the method that would be called by <code>invoke</code> is returned.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L809-L815">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.which-Tuple{Symbol}" href="#Base.which-Tuple{Symbol}"><code>Base.which</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">which(symbol)</code></pre><p>Return the module in which the binding for the variable referenced by <code>symbol</code> was created.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L841-L845">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@which" href="#Base.@which"><code>Base.@which</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@which</code></pre><p>Applied to a function or macro call, it evaluates the arguments to the specified call, and returns the <code>Method</code> object for the method that would be called for those arguments. Applied to a variable, it returns the module in which the variable was bound. It calls out to the <code>which</code> function.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L470-L477">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.methods" href="#Base.methods"><code>Base.methods</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">methods(f, [types])</code></pre><p>Returns the method table for <code>f</code>.</p><p>If <code>types</code> is specified, returns an array of methods whose types match.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L572-L578">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.methodswith" href="#Base.methodswith"><code>Base.methodswith</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">methodswith(typ[, module or function][, showparents::Bool=false])</code></pre><p>Return an array of methods with an argument of type <code>typ</code>.</p><p>The optional second argument restricts the search to a particular module or function (the default is all modules, starting from Main).</p><p>If optional <code>showparents</code> is <code>true</code>, also return arguments with a parent type of <code>typ</code>, excluding type <code>Any</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L553-L563">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@show" href="#Base.@show"><code>Base.@show</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@show</code></pre><p>Show an expression and result, returning the result.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L815-L819">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.versioninfo" href="#Base.versioninfo"><code>Base.versioninfo</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">versioninfo(io::IO=STDOUT, verbose::Bool=false)</code></pre><p>Print information about the version of Julia in use. If the <code>verbose</code> argument is <code>true</code>, detailed system information is shown as well.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L266-L271">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.workspace" href="#Base.workspace"><code>Base.workspace</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">workspace()</code></pre><p>Replace the top-level module (<code>Main</code>) with a new one, providing a clean workspace. The previous <code>Main</code> module is made available as <code>LastMain</code>. A previously-loaded package can be accessed using a statement such as <code>using LastMain.Package</code>.</p><p>This function should only be used interactively.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L667-L675">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="ans" href="#ans"><code>ans</code></a> — <span class="docstring-category">Keyword</span>.</div><div><pre><code class="language-none">ans</code></pre><p>A variable referring to the last computed value, automatically set at the interactive prompt.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/basedocs.jl#L684-L688">source</a></section><h2><a class="nav-anchor" id="All-Objects-1" href="#All-Objects-1">All Objects</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.:===" href="#Core.:==="><code>Core.:===</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">===(x,y) -> Bool
|
|
≡(x,y) -> Bool</code></pre><p>Determine whether <code>x</code> and <code>y</code> are identical, in the sense that no program could distinguish them. Compares mutable objects by address in memory, and compares immutable objects (such as numbers) by contents at the bit level. This function is sometimes called <code>egal</code>.</p><pre><code class="language-julia-repl">julia> a = [1, 2]; b = [1, 2];
|
|
|
|
julia> a == b
|
|
true
|
|
|
|
julia> a === b
|
|
false
|
|
|
|
julia> a === a
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L132-L152">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.isa" href="#Core.isa"><code>Core.isa</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isa(x, type) -> Bool</code></pre><p>Determine whether <code>x</code> is of the given <code>type</code>. Can also be used as an infix operator, e.g. <code>x isa type</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2146-L2151">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isequal-Tuple{Any,Any}" href="#Base.isequal-Tuple{Any,Any}"><code>Base.isequal</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">isequal(x, y)</code></pre><p>Similar to <code>==</code>, except treats all floating-point <code>NaN</code> values as equal to each other, and treats <code>-0.0</code> as unequal to <code>0.0</code>. The default implementation of <code>isequal</code> calls <code>==</code>, so if you have a type that doesn't have these floating-point subtleties then you probably only need to define <code>==</code>.</p><p><code>isequal</code> is the comparison function used by hash tables (<code>Dict</code>). <code>isequal(x,y)</code> must imply that <code>hash(x) == hash(y)</code>.</p><p>This typically means that if you define your own <code>==</code> function then you must define a corresponding <code>hash</code> (and vice versa). Collections typically implement <code>isequal</code> by calling <code>isequal</code> recursively on all contents.</p><p>Scalar types generally do not need to implement <code>isequal</code> separate from <code>==</code>, unless they represent floating-point numbers amenable to a more efficient implementation than that provided as a generic fallback (based on <code>isnan</code>, <code>signbit</code>, and <code>==</code>).</p><pre><code class="language-julia-repl">julia> isequal([1., NaN], [1., NaN])
|
|
true
|
|
|
|
julia> [1., NaN] == [1., NaN]
|
|
false
|
|
|
|
julia> 0.0 == -0.0
|
|
true
|
|
|
|
julia> isequal(0.0, -0.0)
|
|
false</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L54-L86">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isequal-Tuple{Nullable,Nullable}" href="#Base.isequal-Tuple{Nullable,Nullable}"><code>Base.isequal</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">isequal(x, y)</code></pre><p>Similar to <code>==</code>, except treats all floating-point <code>NaN</code> values as equal to each other, and treats <code>-0.0</code> as unequal to <code>0.0</code>. The default implementation of <code>isequal</code> calls <code>==</code>, so if you have a type that doesn't have these floating-point subtleties then you probably only need to define <code>==</code>.</p><p><code>isequal</code> is the comparison function used by hash tables (<code>Dict</code>). <code>isequal(x,y)</code> must imply that <code>hash(x) == hash(y)</code>.</p><p>This typically means that if you define your own <code>==</code> function then you must define a corresponding <code>hash</code> (and vice versa). Collections typically implement <code>isequal</code> by calling <code>isequal</code> recursively on all contents.</p><p>Scalar types generally do not need to implement <code>isequal</code> separate from <code>==</code>, unless they represent floating-point numbers amenable to a more efficient implementation than that provided as a generic fallback (based on <code>isnan</code>, <code>signbit</code>, and <code>==</code>).</p><pre><code class="language-julia-repl">julia> isequal([1., NaN], [1., NaN])
|
|
true
|
|
|
|
julia> [1., NaN] == [1., NaN]
|
|
false
|
|
|
|
julia> 0.0 == -0.0
|
|
true
|
|
|
|
julia> isequal(0.0, -0.0)
|
|
false</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L54-L86">source</a><div><pre><code class="language-none">isequal(x::Nullable, y::Nullable)</code></pre><p>If neither <code>x</code> nor <code>y</code> is null, compare them according to their values (i.e. <code>isequal(get(x), get(y))</code>). Else, return <code>true</code> if both arguments are null, and <code>false</code> if one is null but not the other: nulls are considered equal.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/nullable.jl#L198-L204">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isless" href="#Base.isless"><code>Base.isless</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isless(x, y)</code></pre><p>Test whether <code>x</code> is less than <code>y</code>, according to a canonical total order. Values that are normally unordered, such as <code>NaN</code>, are ordered in an arbitrary but consistent fashion. This is the default comparison used by <a href="sort.html#Base.sort"><code>sort</code></a>. Non-numeric types with a canonical total order should implement this function. Numeric types only need to implement it if they have special values such as <code>NaN</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1743-L1751">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isless-Tuple{Nullable,Nullable}" href="#Base.isless-Tuple{Nullable,Nullable}"><code>Base.isless</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">isless(x::Nullable, y::Nullable)</code></pre><p>If neither <code>x</code> nor <code>y</code> is null, compare them according to their values (i.e. <code>isless(get(x), get(y))</code>). Else, return <code>true</code> if only <code>y</code> is null, and <code>false</code> otherwise: nulls are always considered greater than non-nulls, but not greater than another null.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/nullable.jl#L217-L224">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ifelse" href="#Base.ifelse"><code>Base.ifelse</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">ifelse(condition::Bool, x, y)</code></pre><p>Return <code>x</code> if <code>condition</code> is <code>true</code>, otherwise return <code>y</code>. This differs from <code>?</code> or <code>if</code> in that it is an ordinary function, so all the arguments are evaluated first. In some cases, using <code>ifelse</code> instead of an <code>if</code> statement can eliminate the branch in generated code and provide higher performance in tight loops.</p><pre><code class="language-julia-repl">julia> ifelse(1 > 2, 1, 2)
|
|
2</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L269-L281">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.lexcmp" href="#Base.lexcmp"><code>Base.lexcmp</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">lexcmp(x, y)</code></pre><p>Compare <code>x</code> and <code>y</code> lexicographically and return -1, 0, or 1 depending on whether <code>x</code> is less than, equal to, or greater than <code>y</code>, respectively. This function should be defined for lexicographically comparable types, and <code>lexless</code> will call <code>lexcmp</code> by default.</p><pre><code class="language-julia-repl">julia> lexcmp("abc", "abd")
|
|
-1
|
|
|
|
julia> lexcmp("abc", "abc")
|
|
0</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L305-L319">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.lexless" href="#Base.lexless"><code>Base.lexless</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">lexless(x, y)</code></pre><p>Determine whether <code>x</code> is lexicographically less than <code>y</code>.</p><pre><code class="language-julia-repl">julia> lexless("abc", "abd")
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L322-L331">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.typeof" href="#Core.typeof"><code>Core.typeof</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">typeof(x)</code></pre><p>Get the concrete type of <code>x</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1017-L1021">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.tuple" href="#Core.tuple"><code>Core.tuple</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">tuple(xs...)</code></pre><p>Construct a tuple of the given objects.</p><p><strong>Example</strong></p><pre><code class="language-julia-repl">julia> tuple(1, 'a', pi)
|
|
(1, 'a', π = 3.1415926535897...)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L580-L590">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ntuple" href="#Base.ntuple"><code>Base.ntuple</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">ntuple(f::Function, n::Integer)</code></pre><p>Create a tuple of length <code>n</code>, computing each element as <code>f(i)</code>, where <code>i</code> is the index of the element.</p><pre><code class="language-julia-repl">julia> ntuple(i -> 2*i, 4)
|
|
(2, 4, 6, 8)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/tuple.jl#L96-L106">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.object_id" href="#Base.object_id"><code>Base.object_id</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">object_id(x)</code></pre><p>Get a hash value for <code>x</code> based on object identity. <code>object_id(x)==object_id(y)</code> if <code>x === y</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1829-L1833">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.hash" href="#Base.hash"><code>Base.hash</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">hash(x[, h::UInt])</code></pre><p>Compute an integer hash code such that <code>isequal(x,y)</code> implies <code>hash(x)==hash(y)</code>. The optional second argument <code>h</code> is a hash code to be mixed with the result.</p><p>New types should implement the 2-argument form, typically by calling the 2-argument <code>hash</code> method recursively in order to mix hashes of the contents with each other (and with <code>h</code>). Typically, any type that implements <code>hash</code> should also implement its own <code>==</code> (hence <code>isequal</code>) to guarantee the property mentioned above.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1469-L1479">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.finalizer" href="#Base.finalizer"><code>Base.finalizer</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">finalizer(x, f)</code></pre><p>Register a function <code>f(x)</code> to be called when there are no program-accessible references to <code>x</code>. The type of <code>x</code> must be a <code>mutable struct</code>, otherwise the behavior of this function is unpredictable.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1879-L1885">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.finalize" href="#Base.finalize"><code>Base.finalize</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">finalize(x)</code></pre><p>Immediately run finalizers registered for object <code>x</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1129-L1133">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.copy" href="#Base.copy"><code>Base.copy</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">copy(x)</code></pre><p>Create a shallow copy of <code>x</code>: the outer structure is copied, but not all internal values. For example, copying an array produces a new array with identically-same elements as the original.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1577-L1583">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.deepcopy" href="#Base.deepcopy"><code>Base.deepcopy</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">deepcopy(x)</code></pre><p>Create a deep copy of <code>x</code>: everything is copied recursively, resulting in a fully independent object. For example, deep-copying an array produces a new array whose elements are deep copies of the original elements. Calling <code>deepcopy</code> on an object should generally have the same effect as serializing and then deserializing it.</p><p>As a special case, functions can only be actually deep-copied if they are anonymous, otherwise they are just copied. The difference is only relevant in the case of closures, i.e. functions which may contain hidden internal references.</p><p>While it isn't normally necessary, user-defined types can override the default <code>deepcopy</code> behavior by defining a specialized version of the function <code>deepcopy_internal(x::T, dict::ObjectIdDict)</code> (which shouldn't otherwise be used), where <code>T</code> is the type to be specialized for, and <code>dict</code> keeps track of objects copied so far within the recursion. Within the definition, <code>deepcopy_internal</code> should be used in place of <code>deepcopy</code>, and the <code>dict</code> variable should be updated as appropriate before returning.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2518-L2536">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.isdefined" href="#Core.isdefined"><code>Core.isdefined</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isdefined([m::Module,] s::Symbol)
|
|
isdefined(object, s::Symbol)
|
|
isdefined(object, index::Int)</code></pre><p>Tests whether an assignable location is defined. The arguments can be a module and a symbol or a composite object and field name (as a symbol) or index. With a single symbol argument, tests whether a global variable with that name is defined in <a href="base.html#Base.current_module"><code>current_module()</code></a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1526-L1534">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.convert" href="#Base.convert"><code>Base.convert</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">convert(T, x)</code></pre><p>Convert <code>x</code> to a value of type <code>T</code>.</p><p>If <code>T</code> is an <a href="numbers.html#Core.Integer"><code>Integer</code></a> type, an <a href="base.html#Core.InexactError"><code>InexactError</code></a> will be raised if <code>x</code> is not representable by <code>T</code>, for example if <code>x</code> is not integer-valued, or is outside the range supported by <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> convert(Int, 3.0)
|
|
3
|
|
|
|
julia> convert(Int, 3.5)
|
|
ERROR: InexactError()
|
|
Stacktrace:
|
|
[1] convert(::Type{Int64}, ::Float64) at ./float.jl:679</code></pre><p>If <code>T</code> is a <a href="numbers.html#Core.AbstractFloat"><code>AbstractFloat</code></a> or <a href="numbers.html#Base.Rational"><code>Rational</code></a> type, then it will return the closest value to <code>x</code> representable by <code>T</code>.</p><pre><code class="language-julia-repl">julia> x = 1/3
|
|
0.3333333333333333
|
|
|
|
julia> convert(Float32, x)
|
|
0.33333334f0
|
|
|
|
julia> convert(Rational{Int32}, x)
|
|
1//3
|
|
|
|
julia> convert(Rational{Int64}, x)
|
|
6004799503160661//18014398509481984</code></pre><p>If <code>T</code> is a collection type and <code>x</code> a collection, the result of <code>convert(T, x)</code> may alias <code>x</code>.</p><pre><code class="language-julia-repl">julia> x = Int[1,2,3];
|
|
|
|
julia> y = convert(Vector{Int}, x);
|
|
|
|
julia> y === x
|
|
true</code></pre><p>Similarly, if <code>T</code> is a composite type and <code>x</code> a related instance, the result of <code>convert(T, x)</code> may alias part or all of <code>x</code>.</p><pre><code class="language-julia-repl">julia> x = speye(5);
|
|
|
|
julia> typeof(x)
|
|
SparseMatrixCSC{Float64,Int64}
|
|
|
|
julia> y = convert(SparseMatrixCSC{Float64,Int64}, x);
|
|
|
|
julia> z = convert(SparseMatrixCSC{Float32,Int64}, y);
|
|
|
|
julia> y === x
|
|
true
|
|
|
|
julia> z === x
|
|
false
|
|
|
|
julia> z.colptr === x.colptr
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2173-L2241">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.promote" href="#Base.promote"><code>Base.promote</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">promote(xs...)</code></pre><p>Convert all arguments to their common promotion type (if any), and return them all (as a tuple).</p><p><strong>Example</strong></p><pre><code class="language-julia-repl">julia> promote(Int8(1), Float16(4.5), Float32(4.1))
|
|
(1.0f0, 4.5f0, 4.1f0)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L407-L417">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.oftype" href="#Base.oftype"><code>Base.oftype</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">oftype(x, y)</code></pre><p>Convert <code>y</code> to the type of <code>x</code> (<code>convert(typeof(x), y)</code>).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L377-L381">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.widen" href="#Base.widen"><code>Base.widen</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">widen(x)</code></pre><p>If <code>x</code> is a type, return a "larger" type (for numeric types, this will be a type with at least as much range and precision as the argument, and usually more). Otherwise <code>x</code> is converted to <code>widen(typeof(x))</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> widen(Int32)
|
|
Int64
|
|
|
|
julia> widen(1.5f0)
|
|
1.5</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2539-L2554">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.identity" href="#Base.identity"><code>Base.identity</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">identity(x)</code></pre><p>The identity function. Returns its argument.</p><pre><code class="language-julia-repl">julia> identity("Well, what did you expect?")
|
|
"Well, what did you expect?"</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L387-L396">source</a></section><h2><a class="nav-anchor" id="Types-1" href="#Types-1">Types</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.supertype" href="#Base.supertype"><code>Base.supertype</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">supertype(T::DataType)</code></pre><p>Return the supertype of DataType <code>T</code>.</p><pre><code class="language-julia-repl">julia> supertype(Int32)
|
|
Signed</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L30-L39">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.issubtype" href="#Core.issubtype"><code>Core.issubtype</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">issubtype(type1, type2)</code></pre><p>Return <code>true</code> if and only if all values of <code>type1</code> are also of <code>type2</code>. Can also be written using the <code><:</code> infix operator as <code>type1 <: type2</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> issubtype(Int8, Int32)
|
|
false
|
|
|
|
julia> Int8 <: Integer
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1862-L1876">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.:<:" href="#Base.:<:"><code>Base.:<:</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none"><:(T1, T2)</code></pre><p>Subtype operator, equivalent to <code>issubtype(T1, T2)</code>.</p><pre><code class="language-julia-repl">julia> Float64 <: AbstractFloat
|
|
true
|
|
|
|
julia> Vector{Int} <: AbstractArray
|
|
true
|
|
|
|
julia> Matrix{Float64} <: Matrix{AbstractFloat}
|
|
false</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L5-L20">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.:>:" href="#Base.:>:"><code>Base.:>:</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">>:(T1, T2)</code></pre><p>Supertype operator, equivalent to <code>issubtype(T2, T1)</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L23-L27">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.subtypes" href="#Base.subtypes"><code>Base.subtypes</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">subtypes(T::DataType)</code></pre><p>Return a list of immediate subtypes of DataType <code>T</code>. Note that all currently loaded subtypes are included, including those not visible in the current module.</p><pre><code class="language-julia-repl">julia> subtypes(Integer)
|
|
4-element Array{Union{DataType, UnionAll},1}:
|
|
BigInt
|
|
Bool
|
|
Signed
|
|
Unsigned</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L445-L459">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.typemin" href="#Base.typemin"><code>Base.typemin</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">typemin(T)</code></pre><p>The lowest value representable by the given (real) numeric DataType <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> typemin(Float16)
|
|
-Inf16
|
|
|
|
julia> typemin(Float32)
|
|
-Inf32</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1001-L1014">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.typemax" href="#Base.typemax"><code>Base.typemax</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">typemax(T)</code></pre><p>The highest value representable by the given (real) numeric <code>DataType</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1616-L1620">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.realmin" href="#Base.realmin"><code>Base.realmin</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">realmin(T)</code></pre><p>The smallest in absolute value non-subnormal value representable by the given floating-point DataType <code>T</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2504-L2508">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.realmax" href="#Base.realmax"><code>Base.realmax</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">realmax(T)</code></pre><p>The highest finite value representable by the given floating-point DataType <code>T</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> realmax(Float16)
|
|
Float16(6.55e4)
|
|
|
|
julia> realmax(Float32)
|
|
3.4028235f38</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L974-L987">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.maxintfloat" href="#Base.maxintfloat"><code>Base.maxintfloat</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">maxintfloat(T)</code></pre><p>The largest integer losslessly representable by the given floating-point DataType <code>T</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1316-L1320">source</a><div><pre><code class="language-none">maxintfloat(T, S)</code></pre><p>The largest integer losslessly representable by the given floating-point DataType <code>T</code> that also does not exceed the maximum integer representable by the integer DataType <code>S</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1323-L1328">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.sizeof-Tuple{Type}" href="#Base.sizeof-Tuple{Type}"><code>Base.sizeof</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">sizeof(T)</code></pre><p>Size, in bytes, of the canonical binary representation of the given DataType <code>T</code>, if any.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> sizeof(Float32)
|
|
4
|
|
|
|
julia> sizeof(Complex128)
|
|
16</code></pre><p>If <code>T</code> does not have a specific size, an error is thrown.</p><pre><code class="language-julia-repl">julia> sizeof(Base.LinAlg.LU)
|
|
ERROR: argument is an abstract type; size is indeterminate
|
|
Stacktrace:
|
|
[1] sizeof(::Type{T} where T) at ./essentials.jl:159</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L332-L354">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.eps-Tuple{Type{#s27} where #s27<:AbstractFloat}" href="#Base.eps-Tuple{Type{#s27} where #s27<:AbstractFloat}"><code>Base.eps</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">eps(::Type{T}) where T<:AbstractFloat
|
|
eps()</code></pre><p>Returns the <em>machine epsilon</em> of the floating point type <code>T</code> (<code>T = Float64</code> by default). This is defined as the gap between 1 and the next largest value representable by <code>T</code>, and is equivalent to <code>eps(one(T))</code>.</p><pre><code class="language-julia-repl">julia> eps()
|
|
2.220446049250313e-16
|
|
|
|
julia> eps(Float32)
|
|
1.1920929f-7
|
|
|
|
julia> 1.0 + eps()
|
|
1.0000000000000002
|
|
|
|
julia> 1.0 + eps()/2
|
|
1.0</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/float.jl#L718-L739">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.eps-Tuple{AbstractFloat}" href="#Base.eps-Tuple{AbstractFloat}"><code>Base.eps</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">eps(x::AbstractFloat)</code></pre><p>Returns the <em>unit in last place</em> (ulp) of <code>x</code>. This is the distance between consecutive representable floating point values at <code>x</code>. In most cases, if the distance on either side of <code>x</code> is different, then the larger of the two is taken, that is</p><pre><code class="language-none">eps(x) == max(x-prevfloat(x), nextfloat(x)-x)</code></pre><p>The exceptions to this rule are the smallest and largest finite values (e.g. <code>nextfloat(-Inf)</code> and <code>prevfloat(Inf)</code> for <a href="numbers.html#Core.Float64"><code>Float64</code></a>), which round to the smaller of the values.</p><p>The rationale for this behavior is that <code>eps</code> bounds the floating point rounding error. Under the default <code>RoundNearest</code> rounding mode, if <span>$y$</span> is a real number and <span>$x$</span> is the nearest floating point number to <span>$y$</span>, then</p><div>\[|y-x| \leq \operatorname{eps}(x)/2.\]</div><pre><code class="language-julia-repl">julia> eps(1.0)
|
|
2.220446049250313e-16
|
|
|
|
julia> eps(prevfloat(2.0))
|
|
2.220446049250313e-16
|
|
|
|
julia> eps(2.0)
|
|
4.440892098500626e-16
|
|
|
|
julia> x = prevfloat(Inf) # largest finite Float64
|
|
1.7976931348623157e308
|
|
|
|
julia> x + eps(x)/2 # rounds up
|
|
Inf
|
|
|
|
julia> x + prevfloat(eps(x)/2) # rounds down
|
|
1.7976931348623157e308</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/float.jl#L742-L782">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.promote_type" href="#Base.promote_type"><code>Base.promote_type</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">promote_type(type1, type2)</code></pre><p>Determine a type big enough to hold values of each argument type without loss, whenever possible. In some cases, where no type exists to which both types can be promoted losslessly, some loss is tolerated; for example, <code>promote_type(Int64, Float64)</code> returns <a href="numbers.html#Core.Float64"><code>Float64</code></a> even though strictly, not all <a href="numbers.html#Core.Int64"><code>Int64</code></a> values can be represented exactly as <code>Float64</code> values.</p><pre><code class="language-julia-repl">julia> promote_type(Int64, Float64)
|
|
Float64
|
|
|
|
julia> promote_type(Int32, Int64)
|
|
Int64
|
|
|
|
julia> promote_type(Float32, BigInt)
|
|
BigFloat</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/promotion.jl#L134-L153">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.promote_rule" href="#Base.promote_rule"><code>Base.promote_rule</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">promote_rule(type1, type2)</code></pre><p>Specifies what type should be used by <a href="base.html#Base.promote"><code>promote</code></a> when given values of types <code>type1</code> and <code>type2</code>. This function should not be called directly, but should have definitions added to it for new types as appropriate.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2086-L2092">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.getfield" href="#Core.getfield"><code>Core.getfield</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">getfield(value, name::Symbol)</code></pre><p>Extract a named field from a <code>value</code> of composite type. The syntax <code>a.b</code> calls <code>getfield(a, :b)</code>.</p><p><strong>Example</strong></p><pre><code class="language-julia-repl">julia> a = 1//2
|
|
1//2
|
|
|
|
julia> getfield(a, :num)
|
|
1</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L836-L850">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.setfield!" href="#Core.setfield!"><code>Core.setfield!</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">setfield!(value, name::Symbol, x)</code></pre><p>Assign <code>x</code> to a named field in <code>value</code> of composite type. The syntax <code>a.b = c</code> calls <code>setfield!(a, :b, c)</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1909-L1914">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.fieldoffset" href="#Base.fieldoffset"><code>Base.fieldoffset</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">fieldoffset(type, i)</code></pre><p>The byte offset of field <code>i</code> of a type relative to the data start. For example, we could use it in the following manner to summarize information about a struct:</p><pre><code class="language-julia-repl">julia> structinfo(T) = [(fieldoffset(T,i), fieldname(T,i), fieldtype(T,i)) for i = 1:nfields(T)];
|
|
|
|
julia> structinfo(Base.Filesystem.StatStruct)
|
|
12-element Array{Tuple{UInt64,Symbol,DataType},1}:
|
|
(0x0000000000000000, :device, UInt64)
|
|
(0x0000000000000008, :inode, UInt64)
|
|
(0x0000000000000010, :mode, UInt64)
|
|
(0x0000000000000018, :nlink, Int64)
|
|
(0x0000000000000020, :uid, UInt64)
|
|
(0x0000000000000028, :gid, UInt64)
|
|
(0x0000000000000030, :rdev, UInt64)
|
|
(0x0000000000000038, :size, Int64)
|
|
(0x0000000000000040, :blksize, Int64)
|
|
(0x0000000000000048, :blocks, Int64)
|
|
(0x0000000000000050, :mtime, Float64)
|
|
(0x0000000000000058, :ctime, Float64)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L310-L334">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.fieldtype" href="#Core.fieldtype"><code>Core.fieldtype</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">fieldtype(T, name::Symbol | index::Int)</code></pre><p>Determine the declared type of a field (specified by name or index) in a composite DataType <code>T</code>.</p><pre><code class="language-julia-repl">julia> struct Foo
|
|
x::Int64
|
|
y::String
|
|
end
|
|
|
|
julia> fieldtype(Foo, :x)
|
|
Int64
|
|
|
|
julia> fieldtype(Foo, 2)
|
|
String</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L337-L354">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isimmutable" href="#Base.isimmutable"><code>Base.isimmutable</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isimmutable(v)</code></pre><p>Return <code>true</code> iff value <code>v</code> is immutable. See <a href="../manual/types.html#Mutable-Composite-Types-1">Mutable Composite Types</a> for a discussion of immutability. Note that this function works on values, so if you give it a type, it will tell you that a value of <code>DataType</code> is mutable.</p><pre><code class="language-julia-repl">julia> isimmutable(1)
|
|
true
|
|
|
|
julia> isimmutable([1,2])
|
|
false</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L199-L213">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isbits" href="#Base.isbits"><code>Base.isbits</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isbits(T)</code></pre><p>Return <code>true</code> if <code>T</code> is a "plain data" type, meaning it is immutable and contains no references to other values. Typical examples are numeric types such as <a href="numbers.html#Core.UInt8"><code>UInt8</code></a>, <a href="numbers.html#Core.Float64"><code>Float64</code></a>, and <a href="numbers.html#Base.Complex"><code>Complex{Float64}</code></a>.</p><pre><code class="language-julia-repl">julia> isbits(Complex{Float64})
|
|
true
|
|
|
|
julia> isbits(Complex)
|
|
false</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L218-L232">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isleaftype" href="#Base.isleaftype"><code>Base.isleaftype</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isleaftype(T)</code></pre><p>Determine whether <code>T</code>'s only subtypes are itself and <code>Union{}</code>. This means <code>T</code> is a concrete type that can have instances.</p><pre><code class="language-julia-repl">julia> isleaftype(Complex)
|
|
false
|
|
|
|
julia> isleaftype(Complex{Float32})
|
|
true
|
|
|
|
julia> isleaftype(Vector{Complex})
|
|
true
|
|
|
|
julia> isleaftype(Vector{Complex{Float32}})
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L237-L256">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.typejoin" href="#Base.typejoin"><code>Base.typejoin</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">typejoin(T, S)</code></pre><p>Compute a type that contains both <code>T</code> and <code>S</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1389-L1393">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.typeintersect" href="#Base.typeintersect"><code>Base.typeintersect</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">typeintersect(T, S)</code></pre><p>Compute a type that contains the intersection of <code>T</code> and <code>S</code>. Usually this will be the smallest such type or one close to it.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L301-L306">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Val" href="#Base.Val"><code>Base.Val</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">Val{c}</code></pre><p>Create a "value type" out of <code>c</code>, which must be an <code>isbits</code> value. The intent of this construct is to be able to dispatch on constants, e.g., <code>f(Val{false})</code> allows you to dispatch directly (at compile-time) to an implementation <code>f(::Type{Val{false}})</code>, without having to test the boolean value at runtime.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2574-L2581">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Enums.@enum" href="#Base.Enums.@enum"><code>Base.Enums.@enum</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@enum EnumName[::BaseType] value1[=x] value2[=y]</code></pre><p>Create an <code>Enum{BaseType}</code> subtype with name <code>EnumName</code> and enum member values of <code>value1</code> and <code>value2</code> with optional assigned values of <code>x</code> and <code>y</code>, respectively. <code>EnumName</code> can be used just like other types and enum member values as regular values, such as</p><pre><code class="language-julia-repl">julia> @enum Fruit apple=1 orange=2 kiwi=3
|
|
|
|
julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))"
|
|
f (generic function with 1 method)
|
|
|
|
julia> f(apple)
|
|
"I'm a Fruit with value: 1"</code></pre><p><code>BaseType</code>, which defaults to <a href="numbers.html#Core.Int32"><code>Int32</code></a>, must be a primitive subtype of <code>Integer</code>. Member values can be converted between the enum type and <code>BaseType</code>. <code>read</code> and <code>write</code> perform these conversions automatically.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/Enums.jl#L31-L51">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.instances" href="#Base.instances"><code>Base.instances</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">instances(T::Type)</code></pre><p>Return a collection of all instances of the given type, if applicable. Mostly used for enumerated types (see <code>@enum</code>).</p><pre><code class="language-julia-repl">julia> @enum Color red blue green
|
|
|
|
julia> instances(Color)
|
|
(red::Color = 0, blue::Color = 1, green::Color = 2)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L386-L398">source</a></section><h2><a class="nav-anchor" id="Generic-Functions-1" href="#Generic-Functions-1">Generic Functions</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.Function" href="#Core.Function"><code>Core.Function</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">Function</code></pre><p>Abstract type of all functions.</p><pre><code class="language-julia-repl">julia> isa(+, Function)
|
|
true
|
|
|
|
julia> typeof(sin)
|
|
Base.#sin
|
|
|
|
julia> ans <: Function
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/basedocs.jl#L726-L741">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.method_exists" href="#Base.method_exists"><code>Base.method_exists</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">method_exists(f, Tuple type, world=typemax(UInt)) -> Bool</code></pre><p>Determine whether the given generic function has a method matching the given <code>Tuple</code> of argument types with the upper bound of world age given by <code>world</code>.</p><pre><code class="language-julia-repl">julia> method_exists(length, Tuple{Array})
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L921-L931">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.applicable" href="#Core.applicable"><code>Core.applicable</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">applicable(f, args...) -> Bool</code></pre><p>Determine whether the given generic function has a method applicable to the given arguments.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> function f(x, y)
|
|
x + y
|
|
end;
|
|
|
|
julia> applicable(f, 1)
|
|
false
|
|
|
|
julia> applicable(f, 1, 2)
|
|
true</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2244-L2261">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.invoke" href="#Core.invoke"><code>Core.invoke</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">invoke(f, types <: Tuple, args...)</code></pre><p>Invoke a method for the given generic function matching the specified types, on the specified arguments. The arguments must be compatible with the specified types. This allows invoking a method other than the most specific matching method, which is useful when the behavior of a more general definition is explicitly needed (often as part of the implementation of a more specific method of the same function).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1143-L1151">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.invokelatest" href="#Base.invokelatest"><code>Base.invokelatest</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">invokelatest(f, args...)</code></pre><p>Calls <code>f(args...)</code>, but guarantees that the most recent method of <code>f</code> will be executed. This is useful in specialized circumstances, e.g. long-running event loops or callback functions that may call obsolete versions of a function <code>f</code>. (The drawback is that <code>invokelatest</code> is somewhat slower than calling <code>f</code> directly, and the type of the result cannot be inferred by the compiler.)</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/essentials.jl#L360-L369">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.:|>" href="#Base.:|>"><code>Base.:|></code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">|>(x, f)</code></pre><p>Applies a function to the preceding argument. This allows for easy function chaining.</p><pre><code class="language-julia-repl">julia> [1:5;] |> x->x.^2 |> sum |> inv
|
|
0.01818181818181818</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L852-L861">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.:∘" href="#Base.:∘"><code>Base.:∘</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">f ∘ g</code></pre><p>Compose functions: i.e. <code>(f ∘ g)(args...)</code> means <code>f(g(args...))</code>. The <code>∘</code> symbol can be entered in the Julia REPL (and most editors, appropriately configured) by typing <code>\circ<tab></code>. Example:</p><pre><code class="language-julia-repl">julia> map(uppercase∘hex, 250:255)
|
|
6-element Array{String,1}:
|
|
"FA"
|
|
"FB"
|
|
"FC"
|
|
"FD"
|
|
"FE"
|
|
"FF"</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/operators.jl#L866-L883">source</a></section><h2><a class="nav-anchor" id="Syntax-1" href="#Syntax-1">Syntax</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.eval" href="#Core.eval"><code>Core.eval</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">eval([m::Module], expr::Expr)</code></pre><p>Evaluate an expression in the given module and return the result. Every <code>Module</code> (except those defined with <code>baremodule</code>) has its own 1-argument definition of <code>eval</code>, which evaluates expressions in that module.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L102-L108">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@eval" href="#Base.@eval"><code>Base.@eval</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@eval [mod,] ex</code></pre><p>Evaluate an expression with values interpolated into it using <code>eval</code>. If two arguments are provided, the first is the module to evaluate in.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/essentials.jl#L46-L51">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.evalfile" href="#Base.evalfile"><code>Base.evalfile</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">evalfile(path::AbstractString, args::Vector{String}=String[])</code></pre><p>Load the file using <a href="base.html#Base.include"><code>include</code></a>, evaluate all expressions, and return the value of the last one.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/loading.jl#L603-L608">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.esc" href="#Base.esc"><code>Base.esc</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">esc(e::ANY)</code></pre><p>Only valid in the context of an <code>Expr</code> returned from a macro. Prevents the macro hygiene pass from turning embedded variables into gensym variables. See the <a href="../manual/metaprogramming.html#man-macros-1">Macros</a> section of the Metaprogramming chapter of the manual for more details and examples.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/essentials.jl#L193-L199">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@inbounds" href="#Base.@inbounds"><code>Base.@inbounds</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@inbounds(blk)</code></pre><p>Eliminates array bounds checking within expressions.</p><p>In the example below the bound check of array A is skipped to improve performance.</p><pre><code class="language-julia">function sum(A::AbstractArray)
|
|
r = zero(eltype(A))
|
|
for i = 1:length(A)
|
|
@inbounds r += A[i]
|
|
end
|
|
return r
|
|
end</code></pre><div class="admonition warning"><div class="admonition-title">Warning</div><div class="admonition-text"><p>Using <code>@inbounds</code> may return incorrect results/crashes/corruption for out-of-bounds indices. The user is responsible for checking it manually.</p></div></div></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/essentials.jl#L209-L230">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@inline" href="#Base.@inline"><code>Base.@inline</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@inline</code></pre><p>Give a hint to the compiler that this function is worth inlining.</p><p>Small functions typically do not need the <code>@inline</code> annotation, as the compiler does it automatically. By using <code>@inline</code> on bigger functions, an extra nudge can be given to the compiler to inline it. This is shown in the following example:</p><pre><code class="language-julia">@inline function bigfunction(x)
|
|
#=
|
|
Function Definition
|
|
=#
|
|
end</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L111-L128">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@noinline" href="#Base.@noinline"><code>Base.@noinline</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@noinline</code></pre><p>Prevents the compiler from inlining a function.</p><p>Small functions are typically inlined automatically. By using <code>@noinline</code> on small functions, auto-inlining can be prevented. This is shown in the following example:</p><pre><code class="language-julia">@noinline function smallfunction(x)
|
|
#=
|
|
Function Definition
|
|
=#
|
|
end</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L133-L149">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.gensym" href="#Base.gensym"><code>Base.gensym</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">gensym([tag])</code></pre><p>Generates a symbol which will not conflict with other variable names.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L5-L9">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@gensym" href="#Base.@gensym"><code>Base.@gensym</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@gensym</code></pre><p>Generates a gensym symbol for a variable. For example, <code>@gensym x y</code> is transformed into <code>x = gensym("x"); y = gensym("y")</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L18-L23">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@polly" href="#Base.@polly"><code>Base.@polly</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@polly</code></pre><p>Tells the compiler to apply the polyhedral optimizer Polly to a function.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L173-L177">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.parse-Tuple{Any,Any}" href="#Base.parse-Tuple{Any,Any}"><code>Base.parse</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">parse(str, start; greedy=true, raise=true)</code></pre><p>Parse the expression string and return an expression (which could later be passed to eval for execution). <code>start</code> is the index of the first character to start parsing. If <code>greedy</code> is <code>true</code> (default), <code>parse</code> will try to consume as much input as it can; otherwise, it will stop as soon as it has parsed a valid expression. Incomplete but otherwise syntactically valid expressions will return <code>Expr(:incomplete, "(error message)")</code>. If <code>raise</code> is <code>true</code> (default), syntax errors other than incomplete expressions will raise an error. If <code>raise</code> is <code>false</code>, <code>parse</code> will return an expression that will raise an error upon evaluation.</p><pre><code class="language-julia-repl">julia> parse("x = 3, y = 5", 7)
|
|
(:(y = 5), 13)
|
|
|
|
julia> parse("x = 3, y = 5", 5)
|
|
(:((3, y) = 5), 13)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1154-L1172">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.parse-Tuple{Any}" href="#Base.parse-Tuple{Any}"><code>Base.parse</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">parse(str; raise=true)</code></pre><p>Parse the expression string greedily, returning a single expression. An error is thrown if there are additional characters after the first expression. If <code>raise</code> is <code>true</code> (default), syntax errors will raise an error; otherwise, <code>parse</code> will return an expression that will raise an error upon evaluation.</p><pre><code class="language-julia-repl">julia> parse("x = 3")
|
|
:(x = 3)
|
|
|
|
julia> parse("x = ")
|
|
:($(Expr(:incomplete, "incomplete: premature end of input")))
|
|
|
|
julia> parse("1.0.2")
|
|
ERROR: ParseError("invalid numeric constant \"1.0.\"")
|
|
Stacktrace:
|
|
[...]
|
|
|
|
julia> parse("1.0.2"; raise = false)
|
|
:($(Expr(:error, "invalid numeric constant \"1.0.\"")))</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1175-L1198">source</a></section><h2><a class="nav-anchor" id="Nullables-1" href="#Nullables-1">Nullables</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Nullable" href="#Base.Nullable"><code>Base.Nullable</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">Nullable(x, hasvalue::Bool=true)</code></pre><p>Wrap value <code>x</code> in an object of type <code>Nullable</code>, which indicates whether a value is present. <code>Nullable(x)</code> yields a non-empty wrapper and <code>Nullable{T}()</code> yields an empty instance of a wrapper that might contain a value of type <code>T</code>.</p><p><code>Nullable(x, false)</code> yields <code>Nullable{typeof(x)}()</code> with <code>x</code> stored in the result's <code>value</code> field.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> Nullable(1)
|
|
Nullable{Int64}(1)
|
|
|
|
julia> Nullable{Int64}()
|
|
Nullable{Int64}()
|
|
|
|
julia> Nullable(1, false)
|
|
Nullable{Int64}()
|
|
|
|
julia> dump(Nullable(1, false))
|
|
Nullable{Int64}
|
|
hasvalue: Bool false
|
|
value: Int64 1</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/nullable.jl#L6-L33">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.get-Tuple{Nullable,Any}" href="#Base.get-Tuple{Nullable,Any}"><code>Base.get</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">get(x::Nullable[, y])</code></pre><p>Attempt to access the value of <code>x</code>. Returns the value if it is present; otherwise, returns <code>y</code> if provided, or throws a <code>NullException</code> if not.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/nullable.jl#L78-L83">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isnull" href="#Base.isnull"><code>Base.isnull</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isnull(x)</code></pre><p>Return whether or not <code>x</code> is null for <a href="base.html#Base.Nullable"><code>Nullable</code></a> <code>x</code>; return <code>false</code> for all other <code>x</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia-repl">julia> x = Nullable(1, false)
|
|
Nullable{Int64}()
|
|
|
|
julia> isnull(x)
|
|
true
|
|
|
|
julia> x = Nullable(1, true)
|
|
Nullable{Int64}(1)
|
|
|
|
julia> isnull(x)
|
|
false
|
|
|
|
julia> x = 1
|
|
1
|
|
|
|
julia> isnull(x)
|
|
false</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/nullable.jl#L128-L155">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.unsafe_get" href="#Base.unsafe_get"><code>Base.unsafe_get</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">unsafe_get(x)</code></pre><p>Return the value of <code>x</code> for <a href="base.html#Base.Nullable"><code>Nullable</code></a> <code>x</code>; return <code>x</code> for all other <code>x</code>.</p><p>This method does not check whether or not <code>x</code> is null before attempting to access the value of <code>x</code> for <code>x::Nullable</code> (hence "unsafe").</p><pre><code class="language-julia-repl">julia> x = Nullable(1)
|
|
Nullable{Int64}(1)
|
|
|
|
julia> unsafe_get(x)
|
|
1
|
|
|
|
julia> x = Nullable{String}()
|
|
Nullable{String}()
|
|
|
|
julia> unsafe_get(x)
|
|
ERROR: UndefRefError: access to undefined reference
|
|
Stacktrace:
|
|
[1] unsafe_get(::Nullable{String}) at ./nullable.jl:125
|
|
|
|
julia> x = 1
|
|
1
|
|
|
|
julia> unsafe_get(x)
|
|
1</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/nullable.jl#L94-L124">source</a></section><h2><a class="nav-anchor" id="System-1" href="#System-1">System</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.run" href="#Base.run"><code>Base.run</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">run(command, args...)</code></pre><p>Run a command object, constructed with backticks. Throws an error if anything goes wrong, including the process exiting with a non-zero status.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L643-L648">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.spawn" href="#Base.spawn"><code>Base.spawn</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">spawn(command)</code></pre><p>Run a command object asynchronously, returning the resulting <code>Process</code> object.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1519-L1523">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.DevNull" href="#Base.DevNull"><code>Base.DevNull</code></a> — <span class="docstring-category">Constant</span>.</div><div><pre><code class="language-none">DevNull</code></pre><p>Used in a stream redirect to discard all data written to it. Essentially equivalent to /dev/null on Unix or NUL on Windows. Usage:</p><pre><code class="language-julia">run(pipeline(`cat test.txt`, DevNull))</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/basedocs.jl#L714-L723">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.success" href="#Base.success"><code>Base.success</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">success(command)</code></pre><p>Run a command object, constructed with backticks, and tell whether it was successful (exited with a code of 0). An exception is raised if the process cannot be started.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L672-L677">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.process_running" href="#Base.process_running"><code>Base.process_running</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">process_running(p::Process)</code></pre><p>Determine whether a process is currently running.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L728-L732">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.process_exited" href="#Base.process_exited"><code>Base.process_exited</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">process_exited(p::Process)</code></pre><p>Determine whether a process has exited.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L737-L741">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.kill-Tuple{Base.Process,Integer}" href="#Base.kill-Tuple{Base.Process,Integer}"><code>Base.kill</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">kill(p::Process, signum=SIGTERM)</code></pre><p>Send a signal to a process. The default is to terminate the process.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L705-L709">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Sys.set_process_title" href="#Base.Sys.set_process_title"><code>Base.Sys.set_process_title</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Sys.set_process_title(title::AbstractString)</code></pre><p>Set the process title. No-op on some operating systems.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/sysinfo.jl#L181-L185">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Sys.get_process_title" href="#Base.Sys.get_process_title"><code>Base.Sys.get_process_title</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Sys.get_process_title()</code></pre><p>Get the process title. On some systems, will always return an empty string.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/sysinfo.jl#L169-L173">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.readandwrite" href="#Base.readandwrite"><code>Base.readandwrite</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">readandwrite(command)</code></pre><p>Starts running a command asynchronously, and returns a tuple (stdout,stdin,process) of the output stream and input stream of the process, and the process object itself.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L614-L619">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ignorestatus" href="#Base.ignorestatus"><code>Base.ignorestatus</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">ignorestatus(command)</code></pre><p>Mark a command object so that running it will not throw an error if the result code is non-zero.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L180-L184">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.detach" href="#Base.detach"><code>Base.detach</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">detach(command)</code></pre><p>Mark a command object so that it will be run in a new process group, allowing it to outlive the julia process, and not have Ctrl-C interrupts passed to it.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L189-L193">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Cmd" href="#Base.Cmd"><code>Base.Cmd</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">Cmd(cmd::Cmd; ignorestatus, detach, windows_verbatim, windows_hide, env, dir)</code></pre><p>Construct a new <code>Cmd</code> object, representing an external program and arguments, from <code>cmd</code>, while changing the settings of the optional keyword arguments:</p><ul><li><p><code>ignorestatus::Bool</code>: If <code>true</code> (defaults to <code>false</code>), then the <code>Cmd</code> will not throw an error if the return code is nonzero.</p></li><li><p><code>detach::Bool</code>: If <code>true</code> (defaults to <code>false</code>), then the <code>Cmd</code> will be run in a new process group, allowing it to outlive the <code>julia</code> process and not have Ctrl-C passed to it.</p></li><li><p><code>windows_verbatim::Bool</code>: If <code>true</code> (defaults to <code>false</code>), then on Windows the <code>Cmd</code> will send a command-line string to the process with no quoting or escaping of arguments, even arguments containing spaces. (On Windows, arguments are sent to a program as a single "command-line" string, and programs are responsible for parsing it into arguments. By default, empty arguments and arguments with spaces or tabs are quoted with double quotes <code>"</code> in the command line, and <code>\</code> or <code>"</code> are preceded by backslashes. <code>windows_verbatim=true</code> is useful for launching programs that parse their command line in nonstandard ways.) Has no effect on non-Windows systems.</p></li><li><p><code>windows_hide::Bool</code>: If <code>true</code> (defaults to <code>false</code>), then on Windows no new console window is displayed when the <code>Cmd</code> is executed. This has no effect if a console is already open or on non-Windows systems.</p></li><li><p><code>env</code>: Set environment variables to use when running the <code>Cmd</code>. <code>env</code> is either a dictionary mapping strings to strings, an array of strings of the form <code>"var=val"</code>, an array or tuple of <code>"var"=>val</code> pairs, or <code>nothing</code>. In order to modify (rather than replace) the existing environment, create <code>env</code> by <code>copy(ENV)</code> and then set <code>env["var"]=val</code> as desired.</p></li><li><p><code>dir::AbstractString</code>: Specify a working directory for the command (instead of the current directory).</p></li></ul><p>For any keywords that are not specified, the current settings from <code>cmd</code> are used. Normally, to create a <code>Cmd</code> object in the first place, one uses backticks, e.g.</p><pre><code class="language-none">Cmd(`echo "Hello world"`, ignorestatus=true, detach=false)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L33-L67">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.setenv" href="#Base.setenv"><code>Base.setenv</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">setenv(command::Cmd, env; dir="")</code></pre><p>Set environment variables to use when running the given <code>command</code>. <code>env</code> is either a dictionary mapping strings to strings, an array of strings of the form <code>"var=val"</code>, or zero or more <code>"var"=>val</code> pair arguments. In order to modify (rather than replace) the existing environment, create <code>env</code> by <code>copy(ENV)</code> and then setting <code>env["var"]=val</code> as desired, or use <code>withenv</code>.</p><p>The <code>dir</code> keyword argument can be used to specify a working directory for the command.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L214-L224">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.withenv" href="#Base.withenv"><code>Base.withenv</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">withenv(f::Function, kv::Pair...)</code></pre><p>Execute <code>f()</code> in an environment that is temporarily modified (not replaced as in <code>setenv</code>) by zero or more <code>"var"=>val</code> arguments <code>kv</code>. <code>withenv</code> is generally used via the <code>withenv(kv...) do ... end</code> syntax. A value of <code>nothing</code> can be used to temporarily unset an environment variable (if it is set). When <code>withenv</code> returns, the original environment has been restored.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/env.jl#L142-L150">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.pipeline-Tuple{Any,Any,Any,Vararg{Any,N} where N}" href="#Base.pipeline-Tuple{Any,Any,Any,Vararg{Any,N} where N}"><code>Base.pipeline</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">pipeline(from, to, ...)</code></pre><p>Create a pipeline from a data source to a destination. The source and destination can be commands, I/O streams, strings, or results of other <code>pipeline</code> calls. At least one argument must be a command. Strings refer to filenames. When called with more than two arguments, they are chained together from left to right. For example <code>pipeline(a,b,c)</code> is equivalent to <code>pipeline(pipeline(a,b),c)</code>. This provides a more concise way to specify multi-stage pipelines.</p><p><strong>Examples</strong>:</p><pre><code class="language-julia">run(pipeline(`ls`, `grep xyz`))
|
|
run(pipeline(`ls`, "out.txt"))
|
|
run(pipeline("out.txt", `grep xyz`))</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L283-L300">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.pipeline-Tuple{Base.AbstractCmd}" href="#Base.pipeline-Tuple{Base.AbstractCmd}"><code>Base.pipeline</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">pipeline(command; stdin, stdout, stderr, append=false)</code></pre><p>Redirect I/O to or from the given <code>command</code>. Keyword arguments specify which of the command's streams should be redirected. <code>append</code> controls whether file output appends to the file. This is a more general version of the 2-argument <code>pipeline</code> function. <code>pipeline(from, to)</code> is equivalent to <code>pipeline(from, stdout=to)</code> when <code>from</code> is a command, and to <code>pipeline(to, stdin=from)</code> when <code>from</code> is another kind of data source.</p><p><strong>Examples</strong>:</p><pre><code class="language-julia">run(pipeline(`dothings`, stdout="out.txt", stderr="errs.txt"))
|
|
run(pipeline(`update`, stdout="log.txt", append=true))</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/process.jl#L248-L263">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Libc.gethostname" href="#Base.Libc.gethostname"><code>Base.Libc.gethostname</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">gethostname() -> AbstractString</code></pre><p>Get the local machine's host name.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/libc.jl#L236-L240">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.getipaddr" href="#Base.getipaddr"><code>Base.getipaddr</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">getipaddr() -> IPAddr</code></pre><p>Get the IP address of the local machine.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/socket.jl#L666-L670">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Libc.getpid" href="#Base.Libc.getpid"><code>Base.Libc.getpid</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">getpid() -> Int32</code></pre><p>Get Julia's process ID.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/libc.jl#L227-L231">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Libc.time-Tuple{}" href="#Base.Libc.time-Tuple{}"><code>Base.Libc.time</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">time()</code></pre><p>Get the system time in seconds since the epoch, with fairly high (typically, microsecond) resolution.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1926-L1930">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.time_ns" href="#Base.time_ns"><code>Base.time_ns</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">time_ns()</code></pre><p>Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L9-L13">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.tic" href="#Base.tic"><code>Base.tic</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">tic()</code></pre><p>Set a timer to be read by the next call to <a href="base.html#Base.toc"><code>toc</code></a> or <a href="base.html#Base.toq"><code>toq</code></a>. The macro call <code>@time expr</code> can also be used to time evaluation.</p><pre><code class="language-julia-repl">julia> tic()
|
|
0x0000c45bc7abac95
|
|
|
|
julia> sleep(0.3)
|
|
|
|
julia> toc()
|
|
elapsed time: 0.302745944 seconds
|
|
0.302745944</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L79-L95">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.toc" href="#Base.toc"><code>Base.toc</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">toc()</code></pre><p>Print and return the time elapsed since the last <a href="base.html#Base.tic"><code>tic</code></a>. The macro call <code>@time expr</code> can also be used to time evaluation.</p><pre><code class="language-julia-repl">julia> tic()
|
|
0x0000c45bc7abac95
|
|
|
|
julia> sleep(0.3)
|
|
|
|
julia> toc()
|
|
elapsed time: 0.302745944 seconds
|
|
0.302745944</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L129-L145">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.toq" href="#Base.toq"><code>Base.toq</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">toq()</code></pre><p>Return, but do not print, the time elapsed since the last <a href="base.html#Base.tic"><code>tic</code></a>. The macro calls <code>@timed expr</code> and <code>@elapsed expr</code> also return evaluation time.</p><pre><code class="language-julia-repl">julia> tic()
|
|
0x0000c46477a9675d
|
|
|
|
julia> sleep(0.3)
|
|
|
|
julia> toq()
|
|
0.302251004</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L102-L117">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@time" href="#Base.@time"><code>Base.@time</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@time</code></pre><p>A macro to execute an expression, printing the time it took to execute, the number of allocations, and the total number of bytes its execution caused to be allocated, before returning the value of the expression.</p><p>See also <a href="base.html#Base.@timev"><code>@timev</code></a>, <a href="base.html#Base.@timed"><code>@timed</code></a>, <a href="base.html#Base.@elapsed"><code>@elapsed</code></a>, and <a href="base.html#Base.@allocated"><code>@allocated</code></a>.</p><pre><code class="language-julia-repl">julia> @time rand(10^6);
|
|
0.001525 seconds (7 allocations: 7.630 MiB)
|
|
|
|
julia> @time begin
|
|
sleep(0.3)
|
|
1+1
|
|
end
|
|
0.301395 seconds (8 allocations: 336 bytes)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L212-L232">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@timev" href="#Base.@timev"><code>Base.@timev</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@timev</code></pre><p>This is a verbose version of the <code>@time</code> macro. It first prints the same information as <code>@time</code>, then any non-zero memory allocation counters, and then returns the value of the expression.</p><p>See also <a href="base.html#Base.@time"><code>@time</code></a>, <a href="base.html#Base.@timed"><code>@timed</code></a>, <a href="base.html#Base.@elapsed"><code>@elapsed</code></a>, and <a href="base.html#Base.@allocated"><code>@allocated</code></a>.</p><pre><code class="language-julia-repl">julia> @timev rand(10^6);
|
|
0.001006 seconds (7 allocations: 7.630 MiB)
|
|
elapsed time (ns): 1005567
|
|
bytes allocated: 8000256
|
|
pool allocs: 6
|
|
malloc() calls: 1</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L246-L264">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@timed" href="#Base.@timed"><code>Base.@timed</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@timed</code></pre><p>A macro to execute an expression, and return the value of the expression, elapsed time, total bytes allocated, garbage collection time, and an object with various memory allocation counters.</p><p>See also <a href="base.html#Base.@time"><code>@time</code></a>, <a href="base.html#Base.@timev"><code>@timev</code></a>, <a href="base.html#Base.@elapsed"><code>@elapsed</code></a>, and <a href="base.html#Base.@allocated"><code>@allocated</code></a>.</p><pre><code class="language-julia-repl">julia> val, t, bytes, gctime, memallocs = @timed rand(10^6);
|
|
|
|
julia> t
|
|
0.006634834
|
|
|
|
julia> bytes
|
|
8000256
|
|
|
|
julia> gctime
|
|
0.0055765
|
|
|
|
julia> fieldnames(typeof(memallocs))
|
|
9-element Array{Symbol,1}:
|
|
:allocd
|
|
:malloc
|
|
:realloc
|
|
:poolalloc
|
|
:bigalloc
|
|
:freecall
|
|
:total_time
|
|
:pause
|
|
:full_sweep
|
|
|
|
julia> memallocs.total_time
|
|
5576500</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L336-L373">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@elapsed" href="#Base.@elapsed"><code>Base.@elapsed</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@elapsed</code></pre><p>A macro to evaluate an expression, discarding the resulting value, instead returning the number of seconds it took to execute as a floating-point number.</p><p>See also <a href="base.html#Base.@time"><code>@time</code></a>, <a href="base.html#Base.@timev"><code>@timev</code></a>, <a href="base.html#Base.@timed"><code>@timed</code></a>, and <a href="base.html#Base.@allocated"><code>@allocated</code></a>.</p><pre><code class="language-julia-repl">julia> @elapsed sleep(0.3)
|
|
0.301391426</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L276-L289">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@allocated" href="#Base.@allocated"><code>Base.@allocated</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@allocated</code></pre><p>A macro to evaluate an expression, discarding the resulting value, instead returning the total number of bytes allocated during evaluation of the expression. Note: the expression is evaluated inside a local function, instead of the current context, in order to eliminate the effects of compilation, however, there still may be some allocations due to JIT compilation. This also makes the results inconsistent with the <code>@time</code> macros, which do not try to adjust for the effects of compilation.</p><p>See also <a href="base.html#Base.@time"><code>@time</code></a>, <a href="base.html#Base.@timev"><code>@timev</code></a>, <a href="base.html#Base.@timed"><code>@timed</code></a>, and <a href="base.html#Base.@elapsed"><code>@elapsed</code></a>.</p><pre><code class="language-julia-repl">julia> @allocated rand(10^6)
|
|
8000080</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/util.jl#L304-L321">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.EnvHash" href="#Base.EnvHash"><code>Base.EnvHash</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">EnvHash() -> EnvHash</code></pre><p>A singleton of this type provides a hash table interface to environment variables.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/env.jl#L61-L65">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ENV" href="#Base.ENV"><code>Base.ENV</code></a> — <span class="docstring-category">Constant</span>.</div><div><pre><code class="language-none">ENV</code></pre><p>Reference to the singleton <code>EnvHash</code>, providing a dictionary interface to system environment variables.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/env.jl#L68-L73">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.is_unix" href="#Base.is_unix"><code>Base.is_unix</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">is_unix([os])</code></pre><p>Predicate for testing if the OS provides a Unix-like interface. See documentation in <a href="../manual/handling-operating-system-variation.html#Handling-Operating-System-Variation-1">Handling Operating System Variation</a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/osutils.jl#L3-L8">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.is_apple" href="#Base.is_apple"><code>Base.is_apple</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">is_apple([os])</code></pre><p>Predicate for testing if the OS is a derivative of Apple Macintosh OS X or Darwin. See documentation in <a href="../manual/handling-operating-system-variation.html#Handling-Operating-System-Variation-1">Handling Operating System Variation</a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/osutils.jl#L43-L48">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.is_linux" href="#Base.is_linux"><code>Base.is_linux</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">is_linux([os])</code></pre><p>Predicate for testing if the OS is a derivative of Linux. See documentation in <a href="../manual/handling-operating-system-variation.html#Handling-Operating-System-Variation-1">Handling Operating System Variation</a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/osutils.jl#L19-L24">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.is_bsd" href="#Base.is_bsd"><code>Base.is_bsd</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">is_bsd([os])</code></pre><p>Predicate for testing if the OS is a derivative of BSD. See documentation in <a href="../manual/handling-operating-system-variation.html#Handling-Operating-System-Variation-1">Handling Operating System Variation</a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/osutils.jl#L27-L32">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.is_windows" href="#Base.is_windows"><code>Base.is_windows</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">is_windows([os])</code></pre><p>Predicate for testing if the OS is a derivative of Microsoft Windows NT. See documentation in <a href="../manual/handling-operating-system-variation.html#Handling-Operating-System-Variation-1">Handling Operating System Variation</a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/osutils.jl#L35-L40">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Sys.windows_version" href="#Base.Sys.windows_version"><code>Base.Sys.windows_version</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Sys.windows_version()</code></pre><p>Returns the version number for the Windows NT Kernel as a (major, minor) pair, or <code>(0, 0)</code> if this is not running on Windows.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/sysinfo.jl#L209-L214">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@static" href="#Base.@static"><code>Base.@static</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@static</code></pre><p>Partially evaluates an expression at parse time.</p><p>For example, <code>@static is_windows() ? foo : bar</code> will evaluate <code>is_windows()</code> and insert either <code>foo</code> or <code>bar</code> into the expression. This is useful in cases where a construct would be invalid on other platforms, such as a <code>ccall</code> to a non-existent function. <code>@static if is_apple() foo end</code> and <code>@static foo <&&,||> bar</code> are also valid syntax.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/osutils.jl#L51-L60">source</a></section><h2><a class="nav-anchor" id="Errors-1" href="#Errors-1">Errors</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.error" href="#Base.error"><code>Base.error</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">error(message::AbstractString)</code></pre><p>Raise an <code>ErrorException</code> with the given message.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1761-L1765">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.throw" href="#Core.throw"><code>Core.throw</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">throw(e)</code></pre><p>Throw an object as an exception.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2319-L2323">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.rethrow" href="#Base.rethrow"><code>Base.rethrow</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">rethrow([e])</code></pre><p>Throw an object without changing the current exception backtrace. The default argument is the current exception (if called within a <code>catch</code> block).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/error.jl#L32-L37">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.backtrace" href="#Base.backtrace"><code>Base.backtrace</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">backtrace()</code></pre><p>Get a backtrace object for the current program point.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/error.jl#L41-L45">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.catch_backtrace" href="#Base.catch_backtrace"><code>Base.catch_backtrace</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">catch_backtrace()</code></pre><p>Get the backtrace of the current exception, for use within <code>catch</code> blocks.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/error.jl#L48-L52">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.assert" href="#Base.assert"><code>Base.assert</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">assert(cond)</code></pre><p>Throw an <a href="base.html#Base.AssertionError"><code>AssertionError</code></a> if <code>cond</code> is <code>false</code>. Also available as the macro <code>@assert expr</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L182-L187">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@assert" href="#Base.@assert"><code>Base.@assert</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@assert cond [text]</code></pre><p>Throw an <code>AssertionError</code> if <code>cond</code> is <code>false</code>. Preferred syntax for writing assertions. Message <code>text</code> is optionally displayed upon assertion failure.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1989-L1994">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ArgumentError" href="#Base.ArgumentError"><code>Base.ArgumentError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">ArgumentError(msg)</code></pre><p>The parameters to a function call do not match a valid signature. Argument <code>msg</code> is a descriptive error string.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L27-L32">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.AssertionError" href="#Base.AssertionError"><code>Base.AssertionError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">AssertionError([msg])</code></pre><p>The asserted condition did not evaluate to <code>true</code>. Optional argument <code>msg</code> is a descriptive error string.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L79-L84">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.BoundsError" href="#Core.BoundsError"><code>Core.BoundsError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">BoundsError([a],[i])</code></pre><p>An indexing operation into an array, <code>a</code>, tried to access an out-of-bounds element, <code>i</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1136-L1140">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.DimensionMismatch" href="#Base.DimensionMismatch"><code>Base.DimensionMismatch</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">DimensionMismatch([msg])</code></pre><p>The objects called do not have matching dimensionality. Optional argument <code>msg</code> is a descriptive error string.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L68-L73">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.DivideError" href="#Core.DivideError"><code>Core.DivideError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">DivideError()</code></pre><p>Integer division was attempted with a denominator value of 0.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2661-L2665">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.DomainError" href="#Core.DomainError"><code>Core.DomainError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">DomainError()</code></pre><p>The arguments to a function or constructor are outside the valid domain.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1623-L1627">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.EOFError" href="#Base.EOFError"><code>Base.EOFError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">EOFError()</code></pre><p>No more data was available to read from a file or stream.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L61-L65">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.ErrorException" href="#Core.ErrorException"><code>Core.ErrorException</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">ErrorException(msg)</code></pre><p>Generic error type. The error message, in the <code>.msg</code> field, may provide more specific details.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L693-L697">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.InexactError" href="#Core.InexactError"><code>Core.InexactError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">InexactError()</code></pre><p>Type conversion cannot be done exactly.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1609-L1613">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.InterruptException" href="#Core.InterruptException"><code>Core.InterruptException</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">InterruptException()</code></pre><p>The process was stopped by a terminal interrupt (CTRL+C).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2048-L2052">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.KeyError" href="#Base.KeyError"><code>Base.KeyError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">KeyError(key)</code></pre><p>An indexing operation into an <code>Associative</code> (<code>Dict</code>) or <code>Set</code> like object tried to access or delete a non-existent element.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L37-L42">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.LoadError" href="#Base.LoadError"><code>Base.LoadError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">LoadError(file::AbstractString, line::Int, error)</code></pre><p>An error occurred while <code>include</code>ing, <code>require</code>ing, or <code>using</code> a file. The error specifics should be available in the <code>.error</code> field.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L95-L100">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.MethodError" href="#Base.MethodError"><code>Base.MethodError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">MethodError(f, args)</code></pre><p>A method with the required type signature does not exist in the given generic function. Alternatively, there is no unique most-specific method.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L47-L52">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.NullException" href="#Base.NullException"><code>Base.NullException</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">NullException()</code></pre><p>An attempted access to a <a href="base.html#Base.Nullable"><code>Nullable</code></a> with no defined value.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L2062-L2066">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.OutOfMemoryError" href="#Core.OutOfMemoryError"><code>Core.OutOfMemoryError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">OutOfMemoryError()</code></pre><p>An operation allocated too much memory for either the system or the garbage collector to handle properly.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1121-L1126">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.ReadOnlyMemoryError" href="#Core.ReadOnlyMemoryError"><code>Core.ReadOnlyMemoryError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">ReadOnlyMemoryError()</code></pre><p>An operation tried to write to memory that is read-only.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L357-L361">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.OverflowError" href="#Core.OverflowError"><code>Core.OverflowError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">OverflowError()</code></pre><p>The result of an expression is too large for the specified type and will cause a wraparound.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1822-L1826">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ParseError" href="#Base.ParseError"><code>Base.ParseError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">ParseError(msg)</code></pre><p>The expression passed to the <code>parse</code> function could not be interpreted as a valid Julia expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L17-L22">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Distributed.ProcessExitedException" href="#Base.Distributed.ProcessExitedException"><code>Base.Distributed.ProcessExitedException</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">ProcessExitedException()</code></pre><p>After a client Julia process has exited, further attempts to reference the dead child will throw this exception.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/distributed/cluster.jl#L815-L820">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.StackOverflowError" href="#Core.StackOverflowError"><code>Core.StackOverflowError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">StackOverflowError()</code></pre><p>The function call grew beyond the size of the call stack. This usually happens when a call recurses infinitely.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1666-L1671">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.SystemError" href="#Base.SystemError"><code>Base.SystemError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">SystemError(prefix::AbstractString, [errno::Int32])</code></pre><p>A system call failed with an error code (in the <code>errno</code> global variable).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L3-L7">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.TypeError" href="#Core.TypeError"><code>Core.TypeError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">TypeError(func::Symbol, context::AbstractString, expected::Type, got)</code></pre><p>A type assertion failure, or calling an intrinsic function with an incorrect argument type.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1902-L1906">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.UndefRefError" href="#Core.UndefRefError"><code>Core.UndefRefError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">UndefRefError()</code></pre><p>The item or field is not defined for the given object.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L749-L753">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.UndefVarError" href="#Core.UndefVarError"><code>Core.UndefVarError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">UndefVarError(var::Symbol)</code></pre><p>A symbol in the current scope is not defined.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1775-L1779">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.InitError" href="#Base.InitError"><code>Base.InitError</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">InitError(mod::Symbol, error)</code></pre><p>An error occurred when running a module's <code>__init__</code> function. The actual error thrown is available in the <code>.error</code> field.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/base.jl#L107-L112">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.retry" href="#Base.retry"><code>Base.retry</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">retry(f::Function; delays=ExponentialBackOff(), check=nothing) -> Function</code></pre><p>Returns an anonymous function that calls function <code>f</code>. If an exception arises, <code>f</code> is repeatedly called again, each time <code>check</code> returns <code>true</code>, after waiting the number of seconds specified in <code>delays</code>. <code>check</code> should input <code>delays</code>'s current state and the <code>Exception</code>.</p><p><strong>Examples</strong></p><pre><code class="language-julia">retry(f, delays=fill(5.0, 3))
|
|
retry(f, delays=rand(5:10, 2))
|
|
retry(f, delays=Base.ExponentialBackOff(n=3, first_delay=5, max_delay=1000))
|
|
retry(http_get, check=(s,e)->e.status == "503")(url)
|
|
retry(read, check=(s,e)->isa(e, UVError))(io, 128; all=false)</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/error.jl#L117-L133">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.ExponentialBackOff" href="#Base.ExponentialBackOff"><code>Base.ExponentialBackOff</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">ExponentialBackOff(; n=1, first_delay=0.05, max_delay=10.0, factor=5.0, jitter=0.1)</code></pre><p>A <a href="numbers.html#Core.Float64"><code>Float64</code></a> iterator of length <code>n</code> whose elements exponentially increase at a rate in the interval <code>factor</code> * (1 ± <code>jitter</code>). The first element is <code>first_delay</code> and all elements are clamped to <code>max_delay</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/error.jl#L98-L104">source</a></section><h2><a class="nav-anchor" id="Events-1" href="#Events-1">Events</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Timer-Tuple{Function,Real,Real}" href="#Base.Timer-Tuple{Function,Real,Real}"><code>Base.Timer</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">Timer(callback::Function, delay, repeat=0)</code></pre><p>Create a timer to call the given <code>callback</code> function. The <code>callback</code> is passed one argument, the timer object itself. The callback will be invoked after the specified initial <code>delay</code>, and then repeating with the given <code>repeat</code> interval. If <code>repeat</code> is <code>0</code>, the timer is only triggered once. Times are in seconds. A timer is stopped and has its resources freed by calling <a href="io-network.html#Base.close"><code>close</code></a> on it.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/event.jl#L416-L424">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.Timer" href="#Base.Timer"><code>Base.Timer</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">Timer(delay, repeat=0)</code></pre><p>Create a timer that wakes up tasks waiting for it (by calling <a href="parallel.html#Base.wait"><code>wait</code></a> on the timer object) at a specified interval. Times are in seconds. Waiting tasks are woken with an error when the timer is closed (by <a href="io-network.html#Base.close"><code>close</code></a>. Use <a href="io-network.html#Base.isopen"><code>isopen</code></a> to check whether a timer is still active.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/event.jl#L316-L322">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.AsyncCondition" href="#Base.AsyncCondition"><code>Base.AsyncCondition</code></a> — <span class="docstring-category">Type</span>.</div><div><pre><code class="language-none">AsyncCondition()</code></pre><p>Create a async condition that wakes up tasks waiting for it (by calling <a href="parallel.html#Base.wait"><code>wait</code></a> on the object) when notified from C by a call to <code>uv_async_send</code>. Waiting tasks are woken with an error when the object is closed (by <a href="io-network.html#Base.close"><code>close</code></a>. Use <a href="io-network.html#Base.isopen"><code>isopen</code></a> to check whether it is still active.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/event.jl#L259-L267">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.AsyncCondition-Tuple{Function}" href="#Base.AsyncCondition-Tuple{Function}"><code>Base.AsyncCondition</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">AsyncCondition(callback::Function)</code></pre><p>Create a async condition that calls the given <code>callback</code> function. The <code>callback</code> is passed one argument, the async condition object itself.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/event.jl#L289-L294">source</a></section><h2><a class="nav-anchor" id="Reflection-1" href="#Reflection-1">Reflection</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.module_name" href="#Base.module_name"><code>Base.module_name</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">module_name(m::Module) -> Symbol</code></pre><p>Get the name of a <code>Module</code> as a <code>Symbol</code>.</p><pre><code class="language-julia-repl">julia> module_name(Base.LinAlg)
|
|
:LinAlg</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L5-L14">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.module_parent" href="#Base.module_parent"><code>Base.module_parent</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">module_parent(m::Module) -> Module</code></pre><p>Get a module's enclosing <code>Module</code>. <code>Main</code> is its own parent, as is <code>LastMain</code> after <code>workspace()</code>.</p><pre><code class="language-julia-repl">julia> module_parent(Main)
|
|
Main
|
|
|
|
julia> module_parent(Base.LinAlg.BLAS)
|
|
Base.LinAlg</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L17-L29">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.current_module" href="#Base.current_module"><code>Base.current_module</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">current_module() -> Module</code></pre><p>Get the <em>dynamically</em> current <code>Module</code>, which is the <code>Module</code> code is currently being read from. In general, this is not the same as the module containing the call to this function.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L32-L37">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.fullname" href="#Base.fullname"><code>Base.fullname</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">fullname(m::Module)</code></pre><p>Get the fully-qualified name of a module as a tuple of symbols. For example,</p><pre><code class="language-julia-repl">julia> fullname(Base.Pkg)
|
|
(:Base, :Pkg)
|
|
|
|
julia> fullname(Main)
|
|
()</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L40-L52">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.names" href="#Base.names"><code>Base.names</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">names(x::Module, all::Bool=false, imported::Bool=false)</code></pre><p>Get an array of the names exported by a <code>Module</code>, excluding deprecated names. If <code>all</code> is true, then the list also includes non-exported names defined in the module, deprecated names, and compiler-generated names. If <code>imported</code> is true, then names explicitly imported from other modules are also included.</p><p>As a special case, all names defined in <code>Main</code> are considered "exported", since it is not idiomatic to explicitly export names from <code>Main</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L75-L86">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Core.nfields" href="#Core.nfields"><code>Core.nfields</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">nfields(x::DataType) -> Int</code></pre><p>Get the number of fields of a <code>DataType</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1698-L1702">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.fieldnames" href="#Base.fieldnames"><code>Base.fieldnames</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">fieldnames(x::DataType)</code></pre><p>Get an array of the fields of a <code>DataType</code>.</p><pre><code class="language-julia-repl">julia> fieldnames(Hermitian)
|
|
2-element Array{Symbol,1}:
|
|
:data
|
|
:uplo</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L124-L135">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.fieldname" href="#Base.fieldname"><code>Base.fieldname</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">fieldname(x::DataType, i::Integer)</code></pre><p>Get the name of field <code>i</code> of a <code>DataType</code>.</p><pre><code class="language-julia-repl">julia> fieldname(SparseMatrixCSC,1)
|
|
:m
|
|
|
|
julia> fieldname(SparseMatrixCSC,5)
|
|
:nzval</code></pre></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L107-L119">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.datatype_module" href="#Base.datatype_module"><code>Base.datatype_module</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Base.datatype_module(t::DataType) -> Module</code></pre><p>Determine the module containing the definition of a <code>DataType</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L155-L159">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.datatype_name" href="#Base.datatype_name"><code>Base.datatype_name</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Base.datatype_name(t) -> Symbol</code></pre><p>Get the name of a (potentially UnionAll-wrapped) <code>DataType</code> (without its parent module) as a symbol.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L147-L151">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.isconst" href="#Base.isconst"><code>Base.isconst</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">isconst([m::Module], s::Symbol) -> Bool</code></pre><p>Determine whether a global is declared <code>const</code> in a given <code>Module</code>. The default <code>Module</code> argument is <a href="base.html#Base.current_module"><code>current_module()</code></a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L164-L169">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.function_name" href="#Base.function_name"><code>Base.function_name</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">Base.function_name(f::Function) -> Symbol</code></pre><p>Get the name of a generic <code>Function</code> as a symbol, or <code>:anonymous</code>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L856-L860">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.function_module-Tuple{Function}" href="#Base.function_module-Tuple{Function}"><code>Base.function_module</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">Base.function_module(f::Function) -> Module</code></pre><p>Determine the module containing the (first) definition of a generic function.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L900-L905">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.function_module-Tuple{Any,Any}" href="#Base.function_module-Tuple{Any,Any}"><code>Base.function_module</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">Base.function_module(f::Function, types) -> Module</code></pre><p>Determine the module containing a given definition of a generic function.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L908-L912">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.functionloc-Tuple{Any,Any}" href="#Base.functionloc-Tuple{Any,Any}"><code>Base.functionloc</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">functionloc(f::Function, types)</code></pre><p>Returns a tuple <code>(filename,line)</code> giving the location of a generic <code>Function</code> definition.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L878-L882">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.functionloc-Tuple{Method}" href="#Base.functionloc-Tuple{Method}"><code>Base.functionloc</code></a> — <span class="docstring-category">Method</span>.</div><div><pre><code class="language-none">functionloc(m::Method)</code></pre><p>Returns a tuple <code>(filename,line)</code> giving the location of a <code>Method</code> definition.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L865-L869">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@functionloc" href="#Base.@functionloc"><code>Base.@functionloc</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@functionloc</code></pre><p>Applied to a function or macro call, it evaluates the arguments to the specified call, and returns a tuple <code>(filename,line)</code> giving the location for the method that would be called for those arguments. It calls out to the <code>functionloc</code> function.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L496-L502">source</a></section><h2><a class="nav-anchor" id="Internals-1" href="#Internals-1">Internals</a></h2><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.gc" href="#Base.gc"><code>Base.gc</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">gc()</code></pre><p>Perform garbage collection. This should not generally be used.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1782-L1786">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.gc_enable" href="#Base.gc_enable"><code>Base.gc_enable</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">gc_enable(on::Bool)</code></pre><p>Control whether garbage collection is enabled using a boolean argument (<code>true</code> for enabled, <code>false</code> for disabled). Returns previous GC state. Disabling garbage collection should be used only with extreme caution, as it can cause memory use to grow without bound.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1806-L1812">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.macroexpand" href="#Base.macroexpand"><code>Base.macroexpand</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">macroexpand(x)</code></pre><p>Takes the expression <code>x</code> and returns an equivalent expression with all macros removed (expanded).</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L56-L60">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@macroexpand" href="#Base.@macroexpand"><code>Base.@macroexpand</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@macroexpand</code></pre><p>Return equivalent expression with all macros removed (expanded).</p><p>There is a subtle difference between <code>@macroexpand</code> and <code>macroexpand</code> in that expansion takes place in different contexts. This is best seen in the following example:</p><pre><code class="language-julia-repl">julia> module M
|
|
macro m()
|
|
1
|
|
end
|
|
function f()
|
|
(@macroexpand(@m), macroexpand(:(@m)))
|
|
end
|
|
end
|
|
M
|
|
|
|
julia> macro m()
|
|
2
|
|
end
|
|
@m (macro with 1 method)
|
|
|
|
julia> M.f()
|
|
(1, 2)</code></pre><p>With <code>@macroexpand</code> the expression expands where <code>@macroexpand</code> appears in the code (module <code>M</code> in the example). With <code>macroexpand</code> the expression expands in the current module where the code was finally called (REPL in the example). Note that when calling <code>macroexpand</code> or <code>@macroexpand</code> directly from the REPL, both of these contexts coincide, hence there is no difference.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L63-L94">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.expand" href="#Base.expand"><code>Base.expand</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">expand(x)</code></pre><p>Takes the expression <code>x</code> and returns an equivalent expression in lowered form. See also <a href="base.html#Base.code_lowered"><code>code_lowered</code></a>.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/expr.jl#L48-L53">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.code_lowered" href="#Base.code_lowered"><code>Base.code_lowered</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">code_lowered(f, types)</code></pre><p>Returns an array of lowered ASTs for the methods matching the given generic function and type signature.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L479-L483">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@code_lowered" href="#Base.@code_lowered"><code>Base.@code_lowered</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@code_lowered</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls <a href="base.html#Base.code_lowered"><code>code_lowered</code></a> on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L521-L526">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.code_typed" href="#Base.code_typed"><code>Base.code_typed</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">code_typed(f, types; optimize=true)</code></pre><p>Returns an array of lowered and type-inferred ASTs for the methods matching the given generic function and type signature. The keyword argument <code>optimize</code> controls whether additional optimizations, such as inlining, are also applied.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L766-L772">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@code_typed" href="#Base.@code_typed"><code>Base.@code_typed</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@code_typed</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls <a href="base.html#Base.code_typed"><code>code_typed</code></a> on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L505-L510">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.code_warntype" href="#Base.code_warntype"><code>Base.code_warntype</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">code_warntype([io::IO], f, types)</code></pre><p>Prints lowered and type-inferred ASTs for the methods matching the given generic function and type signature to <code>io</code> which defaults to <code>STDOUT</code>. The ASTs are annotated in such a way as to cause "non-leaf" types to be emphasized (if color is available, displayed in red). This serves as a warning of potential type instability. Not all non-leaf types are particularly problematic for performance, so the results need to be used judiciously. See <a href="../manual/performance-tips.html#man-code-warntype-1"><code>@code_warntype</code></a> for more information.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L335-L344">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@code_warntype" href="#Base.@code_warntype"><code>Base.@code_warntype</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@code_warntype</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls <a href="base.html#Base.code_warntype"><code>code_warntype</code></a> on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L513-L518">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.code_llvm" href="#Base.code_llvm"><code>Base.code_llvm</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">code_llvm([io], f, types)</code></pre><p>Prints the LLVM bitcodes generated for running the method matching the given generic function and type signature to <code>io</code> which defaults to <code>STDOUT</code>.</p><p>All metadata and dbg.* calls are removed from the printed bitcode. Use code_llvm_raw for the full IR.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L732-L739">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@code_llvm" href="#Base.@code_llvm"><code>Base.@code_llvm</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@code_llvm</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls <a href="base.html#Base.code_llvm"><code>code_llvm</code></a> on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L529-L534">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.code_native" href="#Base.code_native"><code>Base.code_native</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">code_native([io], f, types, [syntax])</code></pre><p>Prints the native assembly instructions generated for running the method matching the given generic function and type signature to <code>io</code> which defaults to <code>STDOUT</code>. Switch assembly syntax using <code>syntax</code> symbol parameter set to <code>:att</code> for AT&T syntax or <code>:intel</code> for Intel syntax. Output is AT&T syntax by default.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/reflection.jl#L745-L751">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.@code_native" href="#Base.@code_native"><code>Base.@code_native</code></a> — <span class="docstring-category">Macro</span>.</div><div><pre><code class="language-none">@code_native</code></pre><p>Evaluates the arguments to the function or macro call, determines their types, and calls <a href="base.html#Base.code_native"><code>code_native</code></a> on the resulting expression.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/interactiveutil.jl#L537-L542">source</a></section><section class="docstring"><div class="docstring-header"><a class="docstring-binding" id="Base.precompile" href="#Base.precompile"><code>Base.precompile</code></a> — <span class="docstring-category">Function</span>.</div><div><pre><code class="language-none">precompile(f,args::Tuple{Vararg{Any}})</code></pre><p>Compile the given function <code>f</code> for the argument tuple (of types) <code>args</code>, but do not execute it.</p></div><a class="source-link" target="_blank" href="https://github.com/JuliaLang/julia/blob/d55cadc350d426a95fd967121ba77494d08364c8/base/docs/helpdb/Base.jl#L1404-L1408">source</a></section><footer><hr/><a class="previous" href="../manual/unicode-input.html"><span class="direction">Previous</span><span class="title">Unicode Input</span></a><a class="next" href="collections.html"><span class="direction">Next</span><span class="title">Collections and Data Structures</span></a></footer></article></body></html>
|