Skip to content

Commit 921d515

Browse files
committed
Yet more refactoring of manual
- Adds new section on naming variables and style convention - Refactors linear algebra content out of Arrays - Turn more lists of functions into tables - Documents built-in Exceptions, symbol(), isnan, isinf, isfinite, info, warn - Updates list of vectorized functions and documents @vectorize_?args macros - Turns embedded HTML footnotes into ReST footnotes - Fixes sectioning issue in Arrays - More cross-referencing, especially for non-standard string literals - Minor grammatical, language, spelling cleanup - Remove user-specific output from sample Julia snippets
1 parent 0f0954c commit 921d515

15 files changed

+571
-395
lines changed

doc/manual/arrays.rst

+119-203
Large diffs are not rendered by default.

doc/manual/complex-and-rational-numbers.rst

+15-15
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
******************************
66

77
Julia ships with predefined types representing both complex and rational
8-
numbers, and supports all the mathematical operations discussed in
9-
:ref:`man-mathematical-operations` on them.
10-
Promotions are defined so that operations on any combination of
8+
numbers, and supports all :ref:`standard mathematical operations
9+
<man-mathematical-operations>` on them. :ref:`man-promotions`
10+
are defined so that operations on any combination of
1111
predefined numeric types, whether primitive or composite, behave as
1212
expected.
1313

@@ -20,8 +20,8 @@ The global constant ``im`` is bound to the complex number *i*,
2020
representing the principal square root of -1. It was deemed harmful to
2121
co-opt the name ``i`` for a global constant, since it is such a popular
2222
index variable name. Since Julia allows numeric literals to be
23-
:ref:`juxtaposed with identifiers as
24-
coefficients <man-numeric-literal-coefficients>`,
23+
:ref:`juxtaposed with identifiers as coefficients
24+
<man-numeric-literal-coefficients>`,
2525
this binding suffices to provide convenient syntax for complex numbers,
2626
similar to the traditional mathematical notation::
2727

@@ -144,23 +144,23 @@ versus ``-1 + 0im`` even though ``-1 == -1 + 0im``::
144144
julia> sqrt(-1 + 0im)
145145
0.0 + 1.0im
146146

147-
If you need to construct a complex number using variables, the literal
148-
numeric coefficient notation will not work, although explicitly writing
149-
the multiplication operation will::
147+
The :ref:`literal numeric coefficient notation <numeric-literal-coefficients>`
148+
does work when constructing complex number from variables. Instead, the
149+
multiplication must be explicitly written out::
150150

151151
julia> a = 1; b = 2; a + b*im
152152
1 + 2im
153153

154-
Constructing complex numbers from variable values like this, however,
155-
is not recommended. Use the ``complex`` function to construct a
156-
complex value directly from its real and imaginary parts instead. This
157-
construction is preferred for variable arguments because it is more
158-
efficient than the multiplication and addition construct, but also
159-
because certain values of ``b`` can yield unexpected results::
154+
Hoever, this is *not* recommended; Use the ``complex`` function instead to
155+
construct a complex value directly from its real and imaginary parts.::
160156

161157
julia> complex(a,b)
162158
1 + 2im
163159

160+
This construction avoids the multiplication and addition operations, and also
161+
sidesteps unexpected results that can arise with the former for certain values
162+
of ``b``.
163+
164164
``Inf`` and ``NaN`` propagate through complex numbers in the real
165165
and imaginary parts of a complex number as described in the
166166
:ref:`man-special-floats` section::
@@ -260,7 +260,7 @@ Constructing infinite rational values is acceptable::
260260
julia> typeof(ans)
261261
Rational{Int64}
262262

263-
Trying to construct a NaN rational value, however, is not::
263+
Trying to construct a ``NaN`` rational value, however, is not::
264264

265265
julia> 0//0
266266
invalid rational: 0//0

doc/manual/constructors.rst

+10-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Constructors
55
**************
66

7-
Constructors are functions that create new objects — specifically,
7+
Constructors [#]_ are functions that create new objects — specifically,
88
instances of :ref:`man-composite-types`. In Julia,
99
type objects also serve as constructor functions: they create new
1010
instances of themselves when applied to an argument tuple as a function.
@@ -39,6 +39,15 @@ construct objects with fewer or different types of parameters than they
3939
have fields. Julia's system for object construction addresses all of
4040
these cases and more.
4141

42+
.. [#] Nomenclature: while the term “constructor” generally refers to
43+
the entire function which constructs objects of a type, it is common to
44+
abuse terminology slightly and refer to specific constructor methods as
45+
“constructors”. In such situations, it is generally clear from context
46+
that the term is used to mean “constructor method” rather than
47+
“constructor function”, especially as it is often used in the sense of
48+
singling out a particular method of the constructor from all of the
49+
others.
50+
4251
Outer Constructor Methods
4352
-------------------------
4453

@@ -71,23 +80,6 @@ this are called *outer* constructor methods. Outer constructor methods
7180
can only ever create a new instance by calling another constructor
7281
method, such as the automatically provided default one.
7382

74-
.. raw:: html
75-
76-
<div class="sidebar">
77-
78-
A Note On Nomenclature. While the term “constructor” generally refers to
79-
the entire function which constructs objects of a type, it is common to
80-
abuse terminology slightly and refer to specific constructor methods as
81-
“constructors”. In such situations, it is generally clear from context
82-
that the term is used to mean “constructor method” rather than
83-
“constructor function”, especially as it is often used in the sense of
84-
singling out a particular method of the constructor from all of the
85-
others.
86-
87-
.. raw:: html
88-
89-
</div>
90-
9183
Inner Constructor Methods
9284
-------------------------
9385

@@ -178,11 +170,9 @@ with an explicit constructor::
178170

179171
julia> T1(1.0)
180172
no method T1(Float64,)
181-
in method_missing at /Users/stefan/projects/julia/base/base.jl:58
182173

183174
julia> T2(1.0)
184175
no method T2(Float64,)
185-
in method_missing at /Users/stefan/projects/julia/base/base.jl:58
186176

187177
It is considered good form to provide as few inner constructor methods
188178
as possible: only those taking all arguments explicitly and enforcing
@@ -307,7 +297,6 @@ types of the arguments given to the constructor. Here are some examples::
307297

308298
julia> Point(1,2.5)
309299
no method Point(Int64,Float64)
310-
in method_missing at /Users/stefan/projects/julia/base/base.jl:58
311300

312301
## explicit T ##
313302

@@ -316,14 +305,12 @@ types of the arguments given to the constructor. Here are some examples::
316305

317306
julia> Point{Int64}(1.0,2.5)
318307
no method Point(Float64,Float64)
319-
in method_missing at /Users/stefan/projects/julia/base/base.jl:58
320308

321309
julia> Point{Float64}(1.0,2.5)
322310
Point(1.0,2.5)
323311

324312
julia> Point{Float64}(1,2)
325313
no method Point(Int64,Int64)
326-
in method_missing at /Users/stefan/projects/julia/base/base.jl:58
327314

328315
As you can see, for constructor calls with explicit type parameters, the
329316
arguments must match that specific type: ``Point{Int64}(1,2)`` works,

0 commit comments

Comments
 (0)