<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; parse(Complex128, &quot;1.0+1.0im&quot;)
ERROR: MethodError: no method matching parse(::Type{Complex{Float64}}, ::String)"><pre class="notranslate"><code class="notranslate">julia&gt; parse(Complex128, "1.0+1.0im")
ERROR: MethodError: no method matching parse(::Type{Complex{Float64}}, ::String)
</code></pre></div>
<p dir="auto">However, I can do:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; eval(parse(&quot;1.0+1.0im&quot;))
1.0 + 1.0im
julia&gt; typeof(ans)
Complex{Float64}"><pre class="notranslate"><code class="notranslate">julia&gt; eval(parse("1.0+1.0im"))
1.0 + 1.0im
julia&gt; typeof(ans)
Complex{Float64}
</code></pre></div>
<p dir="auto">But, a bit awkward and will not give me immediate control of the resulting type.</p>
<p dir="auto">Another - not related - strange thing which I've noticed with Complex is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; one(im)
Complex(true,false)
julia&gt; one(0+1im)
1 + 0im"><pre class="notranslate"><code class="notranslate">julia&gt; one(im)
Complex(true,false)
julia&gt; one(0+1im)
1 + 0im
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2680 v4@ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)"><pre class="notranslate"><code class="notranslate">julia&gt; versioninfo()
Julia Version 0.6.1
Commit 0d7248e (2017-10-24 22:15 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2680 v4@ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
</code></pre></div>
<p dir="auto">As <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ChrisRackauckas/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ChrisRackauckas">@ChrisRackauckas</a> points out <a href="https://discourse.julialang.org/t/improve-parse-to-be-able-to-handle-complex-numbers/4095" rel="nofollow">on discourse</a>, this shouldn't really be done in a package because <code class="notranslate">Base.parse</code> and all of the argument types are "owned" by Base.</p>
<p dir="auto">Would also be nice not to have to use horribly inefficient techniques involving <code class="notranslate">eval</code>; see also <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="229550757" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/21935" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/21935/hovercard" href="https://github.com/JuliaLang/julia/issues/21935">#21935</a>.</p>
<p dir="auto">Should be straightforward to implement.   The main question in my mind is how permissive it should be:</p>
<ul dir="auto">
<li>Should it allow arbitrary whitespace between the real and imaginary parts?  e.g. <code class="notranslate">"3+4im"</code> and <code class="notranslate">3   +   4im</code> both allowed?</li>
<li>Should it require <code class="notranslate">im</code>, or accept the common variants <code class="notranslate">im</code>, <code class="notranslate">i</code>, <code class="notranslate">j</code>, and <code class="notranslate">I</code>?</li>
<li>Should it require <code class="notranslate">3+4im</code>, or also allow <code class="notranslate">3+4*im</code>?</li>
<li>Should it support the Fortran style <code class="notranslate">(real,imag)</code>?  (Probably not, since we don't support Fortran-style real literals <code class="notranslate">1.0D+00</code> either.)</li>
</ul>