20 lines
13 KiB
HTML
20 lines
13 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Workflow Tips · 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="introduction.html">Introduction</a></li><li><a class="toctext" href="getting-started.html">Getting Started</a></li><li><a class="toctext" href="variables.html">Variables</a></li><li><a class="toctext" href="integers-and-floating-point-numbers.html">Integers and Floating-Point Numbers</a></li><li><a class="toctext" href="mathematical-operations.html">Mathematical Operations and Elementary Functions</a></li><li><a class="toctext" href="complex-and-rational-numbers.html">Complex and Rational Numbers</a></li><li><a class="toctext" href="strings.html">Strings</a></li><li><a class="toctext" href="functions.html">Functions</a></li><li><a class="toctext" href="control-flow.html">Control Flow</a></li><li><a class="toctext" href="variables-and-scoping.html">Scope of Variables</a></li><li><a class="toctext" href="types.html">Types</a></li><li><a class="toctext" href="methods.html">Methods</a></li><li><a class="toctext" href="constructors.html">Constructors</a></li><li><a class="toctext" href="conversion-and-promotion.html">Conversion and Promotion</a></li><li><a class="toctext" href="interfaces.html">Interfaces</a></li><li><a class="toctext" href="modules.html">Modules</a></li><li><a class="toctext" href="documentation.html">Documentation</a></li><li><a class="toctext" href="metaprogramming.html">Metaprogramming</a></li><li><a class="toctext" href="arrays.html">Multi-dimensional Arrays</a></li><li><a class="toctext" href="linear-algebra.html">Linear algebra</a></li><li><a class="toctext" href="networking-and-streams.html">Networking and Streams</a></li><li><a class="toctext" href="parallel-computing.html">Parallel Computing</a></li><li><a class="toctext" href="dates.html">Date and DateTime</a></li><li><a class="toctext" href="interacting-with-julia.html">Interacting With Julia</a></li><li><a class="toctext" href="running-external-programs.html">Running External Programs</a></li><li><a class="toctext" href="calling-c-and-fortran-code.html">Calling C and Fortran Code</a></li><li><a class="toctext" href="handling-operating-system-variation.html">Handling Operating System Variation</a></li><li><a class="toctext" href="environment-variables.html">Environment Variables</a></li><li><a class="toctext" href="embedding.html">Embedding Julia</a></li><li><a class="toctext" href="packages.html">Packages</a></li><li><a class="toctext" href="profile.html">Profiling</a></li><li><a class="toctext" href="stacktraces.html">Stack Traces</a></li><li><a class="toctext" href="performance-tips.html">Performance Tips</a></li><li class="current"><a class="toctext" href="workflow-tips.html">Workflow Tips</a><ul class="internal"><li><a class="toctext" href=
|
||
|
|
||
|
<your definitions here>
|
||
|
|
||
|
end</code></pre></li><li><p><strong>Put your test code in another file.</strong> Create another file, say <code>tst.jl</code>, which begins with</p><pre><code class="language-julia">import Tmp</code></pre><p>and includes tests for the contents of <code>Tmp</code>. The value of using <code>import</code> versus <code>using</code> is that you can call <code>reload("Tmp")</code> instead of having to restart the REPL when your definitions change. Of course, the cost is the need to prepend <code>Tmp.</code> to uses of names defined in your module. (You can lower that cost by keeping your module name short.)</p><p>Alternatively, you can wrap the contents of your test file in a module, as</p><pre><code class="language-none">module Tst
|
||
|
using Tmp
|
||
|
|
||
|
<scratch work>
|
||
|
|
||
|
end</code></pre><p>The advantage is that you can now do <code>using Tmp</code> in your test code and can therefore avoid prepending <code>Tmp.</code> everywhere. The disadvantage is that code can no longer be selectively copied to the REPL without some tweaking.</p></li><li><p><strong>Lather. Rinse. Repeat.</strong> Explore ideas at the <code>julia</code> command prompt. Save good ideas in <code>tst.jl</code>. Occasionally restart the REPL, issuing</p><pre><code class="language-julia">reload("Tmp")
|
||
|
include("tst.jl")</code></pre></li></ul><h3><a class="nav-anchor" id="Simplify-initialization-1" href="#Simplify-initialization-1">Simplify initialization</a></h3><p>To simplify restarting the REPL, put project-specific initialization code in a file, say <code>_init.jl</code>, which you can run on startup by issuing the command:</p><pre><code class="language-none">julia -L _init.jl</code></pre><p>If you further add the following to your <code>.juliarc.jl</code> file</p><pre><code class="language-julia">isfile("_init.jl") && include(joinpath(pwd(), "_init.jl"))</code></pre><p>then calling <code>julia</code> from that directory will run the initialization code without the additional command line argument.</p><h2><a class="nav-anchor" id="Browser-based-workflow-1" href="#Browser-based-workflow-1">Browser-based workflow</a></h2><p>It is also possible to interact with a Julia REPL in the browser via <a href="https://github.com/JuliaLang/IJulia.jl">IJulia</a>. See the package home for details.</p><footer><hr/><a class="previous" href="performance-tips.html"><span class="direction">Previous</span><span class="title">Performance Tips</span></a><a class="next" href="style-guide.html"><span class="direction">Next</span><span class="title">Style Guide</span></a></footer></article></body></html>
|