diff --git a/.travis.yml b/.travis.yml index 2c289f71b91ea..9e712dea95f43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,16 +41,7 @@ before_install: make $BUILDOPTS -C contrib -f repackage_system_suitesparse4.make; fi script: - - if git --no-pager grep --color -n --full-name ' $' -- \*.jl \*.scm \*.c \*.cpp \*.h; then - echo "Error trailing whitespace found in source file(s)"; - echo ""; - echo "This can often be fixed with:"; - echo " git rebase --whitespace=fix HEAD~1"; - echo "or"; - echo " git rebase --whitespace=fix master"; - echo "and then a forced push of the correct branch"; - exit 1; - fi + - make check-whitespace || exit 1 - make $BUILDOPTS prefix=/tmp/julia install - if [ `uname` = "Darwin" ]; then for name in spqr umfpack colamd cholmod amd suitesparse_wrapper; do diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64c17b2cbc887..2f52514a3d59e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,24 +50,24 @@ For developers who need to wrap C libraries so that they can be called from Juli Julia's documentation is stored in the `doc` directory, and like everything else can be modified using `git`. However, for small changes one can also use GitHub's web interface: -- Navigate to https://github.com/JuliaLang/julia -- Click `doc` +- Navigate to https://github.com/JuliaLang/julia +- Click `doc` - If you want to modify an entry in the help for Julia's standard library, click `stdlib` - Pick the file you want to edit (for example, `base.rst`) - Select the `master` branch (if not browsing it already) -- Click "Edit" -- Click on the icon that looks like a fullscreen symbol ("Zen" mode) +- Click "Edit" +- Click on the icon that looks like a fullscreen symbol ("Zen" mode) - Search for the function you want to change -- Make your changes -- Exit Zen mode -- Provide a title, and optionally a longer description of your change +- Make your changes +- Exit Zen mode +- Provide a title, and optionally a longer description of your change - Submit your change Julia's documentation is built with [Sphinx](http://sphinx-doc.org/contents.html), which supports (and Julia's docs rely heavily on) [ReST directives](http://docutils.sourceforge.net/docs/ref/rst/directives.html). To build the documentation locally, run make -C doc html -or +or make -C doc latex @@ -86,7 +86,7 @@ Add new code to Julia's base libraries as follows: 1. Edit the appropriate file in the `base/` directory, or add new files if necessary. Create tests for your functionality and add them to files in the `test/` directory. If you're editing C or Scheme code, most likely it lives in `src/` or one of its subdirectories, although some aspects of Julia's REPL initialization live in `ui/`. 2. Add any new files to `sysimg.jl` in order to build them into the Julia system image. - + 3. Add any necessary export symbols in `exports.jl`. 4. Include your tests in `test/Makefile` and `test/runtests.jl`. diff --git a/LICENSE.md b/LICENSE.md index 0d414f0c69709..6fb14f7a8e1bc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -5,9 +5,9 @@ for exceptions. > Copyright (c) 2009-2014: Jeff Bezanson, Stefan Karpinski, Viral B. Shah, > and other contributors: -> +> > https://github.com/JuliaLang/julia/contributors -> +> > Permission is hereby granted, free of charge, to any person obtaining > a copy of this software and associated documentation files (the > "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ for exceptions. > distribute, sublicense, and/or sell copies of the Software, and to > permit persons to whom the Software is furnished to do so, subject to > the following conditions: -> +> > The above copyright notice and this permission notice shall be > included in all copies or substantial portions of the Software. -> +> > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND diff --git a/Make.inc b/Make.inc index ff5e68c3de118..ccf6cbd9cceac 100644 --- a/Make.inc +++ b/Make.inc @@ -244,7 +244,7 @@ FC_BASE = $(CROSS_COMPILE)gfortran endif FC = $(FC_BASE) -STDLIBCPP_FLAG = +STDLIBCPP_FLAG = ifeq ($(OS), Darwin) DARWINVER := $(shell uname -r | cut -b 1-2) @@ -260,7 +260,7 @@ else ifeq ($(DARWINVER_GTE13),1) USE_LIBCPP = 1 STDLIBCPP_FLAG = -stdlib=libstdc++ -else +else USE_LIBCPP = 0 endif USEGCC = 0 diff --git a/Makefile b/Makefile index ce98788df1f54..32b7e5f6377f5 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ debug release: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/ju check-whitespace: ifneq ($(NO_GIT), 1) - contrib/check-whitespace.sh + @contrib/check-whitespace.sh else $(warn "Skipping whitespace check because git is unavailable") endif @@ -275,7 +275,7 @@ endif ifeq ($(USE_SYSTEM_LIBUV),0) ifeq ($(OS),WINNT) $(INSTALL_F) $(build_includedir)/tree.h $(DESTDIR)$(includedir)/julia -endif +endif $(INSTALL_F) $(build_includedir)/uv* $(DESTDIR)$(includedir)/julia endif $(INSTALL_F) src/julia.h src/julia_version.h src/options.h src/support/*.h $(DESTDIR)$(includedir)/julia @@ -295,7 +295,7 @@ endif # Remove various files which should not be installed -rm -f $(DESTDIR)$(datarootdir)/julia/base/version_git.sh -rm -f $(DESTDIR)$(datarootdir)/julia/test/Makefile - # Copy in beautiful new man page + # Copy in beautiful new man page $(INSTALL_F) $(build_man1dir)/julia.1 $(DESTDIR)$(man1dir)/ # Copy icon and .desktop file mkdir -p $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/ diff --git a/README.md b/README.md index 26bd7b7bad297..1c9ba67ebf1be 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,7 @@ Building Julia requires that the following software be installed: Julia uses the following external libraries, which are automatically downloaded (or in a few cases, included in the Julia source repository) and then compiled from source the first time you run `make`: -- **[LLVM]** (3.3) — compiler infrastructure. (3.4 not supported; 3.5+ mostly supported, [with caveats](https://github.com/JuliaLang/julia/issues/9336)) +- **[LLVM]** (3.3) — compiler infrastructure. (3.4 not supported; 3.5+ mostly supported, [with caveats](https://github.com/JuliaLang/julia/issues/9336)) - **[FemtoLisp]** — packaged with Julia source, and used to implement the compiler front-end. - **[libuv]** — portable, high-performance event-based I/O library - **[OpenLibm]** — portable libm library containing elementary math functions. @@ -288,7 +288,7 @@ Julia uses the following external libraries, which are automatically downloaded - **[libgit2]** (>= 0.21) — Git linkable library, used by Julia's package manager - **[libmojibake]** - fork of [utf8proc], a library for processing UTF-8 encoded Unicode strings - **[libosxunwind]** - clone of [libunwind], a library that determines the call-chain of a program -- **[Rmath]** - library for commonly used special functions +- **[Rmath]** - library for commonly used special functions For a longer overview of Julia's dependencies, see these [slides](https://github.com/tkelman/BAJUtalk-Dec2014/blob/master/BAJUtalkDec2014.pdf?raw=true). diff --git a/README.windows.md b/README.windows.md index 5363d266acd63..4f6adc229755c 100644 --- a/README.windows.md +++ b/README.windows.md @@ -37,9 +37,9 @@ Julia uses binary-mode files exclusively. Unlike many other Windows programs, if git config --global core.eol lf git config --global core.autocrlf input - + or edit `%USERPROFILE%\.gitconfig` and add/edit the lines: - + [core] eol = lf autocrlf = input @@ -289,7 +289,7 @@ If you are building for 64-bit windows, the steps are essentially the same. Just ### Build process is slow/eats memory/hangs my computer -- Disable the Windows [Superfetch](http://en.wikipedia.org/wiki/Windows_Vista_I/O_technologies#SuperFetch) and +- Disable the Windows [Superfetch](http://en.wikipedia.org/wiki/Windows_Vista_I/O_technologies#SuperFetch) and [Program Compatibility Assistant](http://blogs.msdn.com/b/cjacks/archive/2011/11/22/managing-the-windows-7-program-compatibility-assistant-pca.aspx) services, as they are known to have [spurious interactions]((https://cygwin.com/ml/cygwin/2011-12/msg00058.html)) with MinGW/Cygwin. diff --git a/appveyor.yml b/appveyor.yml index 0137fe1d88846..499b585cf73b1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,7 @@ branches: skip_commits: # Add [av skip] to commit messages for docfixes, etc to reduce load on queue - message: /\[av skip\]/ + message: /\[av skip\]/ notifications: - provider: Email diff --git a/contrib/check-whitespace.sh b/contrib/check-whitespace.sh index 6b421e792126f..9e176ac2a256a 100755 --- a/contrib/check-whitespace.sh +++ b/contrib/check-whitespace.sh @@ -12,21 +12,23 @@ file_patterns=' *.jl *.lsp *.scm +*.inc +*.make +*.md +*.rst +*.sh +*.yml +*Makefile ' -# These patterns are disabled until the respective source files are -# corrected: -# *.inc -# *.make -# *.md -# *.rst -# *.sh -# *.yml -# *Makefile - -# TODO: Look also for trailing empty lines, and missing '\n' after the -# last line +# TODO: Look also for trailing empty lines, and missing '\n' after the last line if git --no-pager grep --color -n --full-name -e ' $' -- $file_patterns; then echo "Error: trailing whitespace found in source file(s)" + echo "" + echo "This can often be fixed with:" + echo " git rebase --whitespace=fix HEAD~1" + echo "or" + echo " git rebase --whitespace=fix master" + echo "and then a forced push of the correct branch" exit 1 fi diff --git a/contrib/mac/app/run-install-name-tool-change.sh b/contrib/mac/app/run-install-name-tool-change.sh index 3a3b6a88118d5..3a0ccb107550d 100755 --- a/contrib/mac/app/run-install-name-tool-change.sh +++ b/contrib/mac/app/run-install-name-tool-change.sh @@ -22,4 +22,4 @@ elif [ "x$ACTION" == "xid" ]; then lib="`otool -D $LIBRARY 2>/dev/null | grep ^$WRONG_PREFIX`" install_name_tool -id "$RIGHT_PREFIX/$lib" $LIBRARY; fi - + diff --git a/contrib/mac/mac-gtk.sh b/contrib/mac/mac-gtk.sh index 27ff01c8371ac..f0b4fe5036406 100644 --- a/contrib/mac/mac-gtk.sh +++ b/contrib/mac/mac-gtk.sh @@ -1,6 +1,6 @@ #/bin/sh -# This script will attempt to download and build GTK+-3, +# This script will attempt to download and build GTK+-3, # including dependencies, in ~/gtk (also puts stuff in # ~/.local, ~/Source, ~/.jhbuildrc*) # While this should work, it may be preferable to execute diff --git a/contrib/repackage_system_suitesparse4.make b/contrib/repackage_system_suitesparse4.make index f0dcaf2135968..3a619d7935113 100755 --- a/contrib/repackage_system_suitesparse4.make +++ b/contrib/repackage_system_suitesparse4.make @@ -1,4 +1,4 @@ -#!/usr/bin/make -f +#!/usr/bin/make -f JULIAHOME = $(abspath ..) include $(JULIAHOME)/Make.inc @@ -35,4 +35,4 @@ default: $(INSTALL_NAME_CMD)libumfpack.$(SHLIB_EXT) $(build_libdir)/libumfpack.$(SHLIB_EXT) $(CXX) -shared $(WHOLE_ARCHIVE) $(SS_LIB)/libsuitesparseconfig.a $(SS_LIB)/libspqr.a $(NO_WHOLE_ARCHIVE) -o $(build_libdir)/libspqr.$(SHLIB_EXT) $(LDFLAGS) $(LIBBLAS) -L$(build_libdir) -lcolamd -lccolamd -lcamd -lamd -lcholmod $(RPATH_ORIGIN) $(INSTALL_NAME_CMD)libspqr.$(SHLIB_EXT) $(build_libdir)/libspqr.$(SHLIB_EXT) - + diff --git a/doc/README.md b/doc/README.md index b5e72851fa428..a6e1e4085e902 100644 --- a/doc/README.md +++ b/doc/README.md @@ -36,7 +36,7 @@ File layout conf.py Sphinx configuration helpdb.jl REPL help database stdlib/ Julia standard library documentation - UNDOCUMENTED.rst Undocumented functions (to be filled in and copied to + UNDOCUMENTED.rst Undocumented functions (to be filled in and copied to the correct location in stdlib/) Sphinx extensions and theme diff --git a/doc/devdocs/debuggingtips.rst b/doc/devdocs/debuggingtips.rst index d5a8fa0c85cc3..de72ab21a8d6d 100644 --- a/doc/devdocs/debuggingtips.rst +++ b/doc/devdocs/debuggingtips.rst @@ -51,7 +51,7 @@ Another useful frame is ``to_function(jl_lambda_info_t *li, bool cstyle)``. The #2 0x00007ffff7928bf7 in to_function (li=0x2812060, cstyle=false) at codegen.cpp:584 584 abort(); (gdb) p jl_(jl_uncompress_ast(li,li.ast)) - + Inserting breakpoints upon certain conditions --------------------------------------------- diff --git a/doc/devdocs/llvm.rst b/doc/devdocs/llvm.rst index 7f28ba63ecfed..bcbbd6dc1a0d6 100644 --- a/doc/devdocs/llvm.rst +++ b/doc/devdocs/llvm.rst @@ -12,7 +12,7 @@ Overview of Julia to LLVM Interface Julia statically links in LLVM by default. Build with ``USE_LLVM_SHLIB=1`` to link dynamically. -The code for lowering Julia AST to LLVM IR or interpreting it directly is in +The code for lowering Julia AST to LLVM IR or interpreting it directly is in directory ``src/``. +---------------------+-------------------------------------------------------------+ diff --git a/doc/devdocs/meta.rst b/doc/devdocs/meta.rst index 927c0abf034d6..93f38d0ece72f 100644 --- a/doc/devdocs/meta.rst +++ b/doc/devdocs/meta.rst @@ -19,7 +19,7 @@ the implementation of the ``@inline`` macro:: macro inline(ex) esc(_inline(ex)) end - + _inline(ex::Expr) = pushmeta!(ex, :inline) _inline(arg) = arg diff --git a/doc/devdocs/sysimg.rst b/doc/devdocs/sysimg.rst index 6d2f1f0062b1c..5f65ef14793ef 100644 --- a/doc/devdocs/sysimg.rst +++ b/doc/devdocs/sysimg.rst @@ -23,7 +23,7 @@ Julia now ships with a script that automates the tasks of building the system im This will include a ``build_sysimg()`` function: .. function:: build_sysimg(sysimg_path=default_sysimg_path, cpu_target="native", userimg_path=nothing; force=false) - + Rebuild the system image. Store it in ``sysimg_path``, which defaults to a file named ``sys.ji`` that sits in the same folder as ``libjulia.{so,dylib}``, except on Windows where it defaults to ``JULIA_HOME/../lib/julia/sys.ji``. Use the cpu instruction set given by ``cpu_target``. Valid CPU targets are the same as for the ``-C`` option to ``julia``, or the ``-march`` option to ``gcc``. Defaults to ``native``, which means to use all CPU instructions available on the current processor. Include the user image file given by ``userimg_path``, which should contain directives such as ``using MyPackage`` to include that package in the new system image. diff --git a/doc/manual/calling-c-and-fortran-code.rst b/doc/manual/calling-c-and-fortran-code.rst index e457d548eb4ef..dcaeb45ca92b6 100644 --- a/doc/manual/calling-c-and-fortran-code.rst +++ b/doc/manual/calling-c-and-fortran-code.rst @@ -1,7 +1,7 @@ .. _man-calling-c-and-fortran-code: **************************** - Calling C and Fortran Code + Calling C and Fortran Code **************************** Though most code can be written in Julia, there are many high-quality, @@ -26,7 +26,7 @@ possible to perform whole-program optimizations that can even optimize across this boundary, but Julia does not yet support that. In the future, however, it may do so, yielding even greater performance gains.) -Shared libraries and functions are referenced by a tuple of the +Shared libraries and functions are referenced by a tuple of the form ``(:function, "library")`` or ``("function", "library")`` where ``function`` is the C-exported function name. ``library`` refers to the shared library name: shared libraries available in the (platform-specific) load path @@ -304,7 +304,7 @@ A C function declared to return ``void`` will give ``nothing`` in Julia. For string arguments (``char*``) the Julia type should be ``Ptr{UInt8}``, not ``ASCIIString``. C functions that take an argument of the type ``char**`` -can be called by using a ``Ptr{Ptr{UInt8}}`` type within Julia. For example, +can be called by using a ``Ptr{Ptr{UInt8}}`` type within Julia. For example, C functions of the form:: int main(int argc, char **argv); @@ -394,7 +394,7 @@ the ccall. ccall automatically arranges that all of its arguments will be preserved from garbage collection until the call returns. If a C API will store a reference to memory allocated by Julia, after the ccall returns, you must arrange that the object remains visible to the garbage collector. The -suggested way to handle this is to make a global variable of type +suggested way to handle this is to make a global variable of type ``Array{Any,1}`` to hold these values, until C interface notifies you that it is finished with them. @@ -405,10 +405,10 @@ of the buffer, so that it is safe to free (or alter) the original data without affecting Julia. A notable exception is ``pointer_to_array()`` which, for performance reasons, shares (or can be told to take ownership of) the underlying buffer. -The garbage collector does not guarantee any order of finalization. That is, if ``a`` -contained a reference to ``b`` and both ``a`` and ``b`` are due for garbage +The garbage collector does not guarantee any order of finalization. That is, if ``a`` +contained a reference to ``b`` and both ``a`` and ``b`` are due for garbage collection, there is no guarantee that ``b`` would be finalized after ``a``. If -proper finalization of ``a`` depends on ``b`` being valid, it must be handled in +proper finalization of ``a`` depends on ``b`` being valid, it must be handled in other ways. @@ -443,7 +443,7 @@ Calling Convention The second argument to ``ccall`` can optionally be a calling convention specifier (immediately preceding return type). Without any specifier, -the platform-default C calling convention is used. Other supported +the platform-default C calling convention is used. Other supported conventions are: ``stdcall``, ``cdecl``, ``fastcall``, and ``thiscall``. For example (from base/libc.jl):: @@ -543,7 +543,7 @@ For more details on how to pass callbacks to C libraries, see this C++ --- -Limited support for C++ is provided by the `Cpp `_ +Limited support for C++ is provided by the `Cpp `_ and `Clang `_ packages. Handling Platform Variations @@ -552,7 +552,7 @@ Handling Platform Variations When dealing with platform libraries, it is often necessary to provide special cases for various platforms. The variable ``OS_NAME`` can be used to write these special cases. Additionally, there are several macros intended to make this easier: -``@windows``, ``@unix``, ``@linux``, and ``@osx``. Note that linux and osx are mutually +``@windows``, ``@unix``, ``@linux``, and ``@osx``. Note that linux and osx are mutually exclusive subsets of unix. Their usage takes the form of a ternary conditional operator, as demonstrated in the following examples. diff --git a/doc/manual/complex-and-rational-numbers.rst b/doc/manual/complex-and-rational-numbers.rst index 597916498ead4..6256168b8f5c4 100644 --- a/doc/manual/complex-and-rational-numbers.rst +++ b/doc/manual/complex-and-rational-numbers.rst @@ -3,7 +3,7 @@ .. currentmodule:: Base ****************************** - Complex and Rational Numbers + Complex and Rational Numbers ****************************** Julia ships with predefined types representing both complex and rational @@ -185,7 +185,7 @@ construct a complex value directly from its real and imaginary parts.: This construction avoids the multiplication and addition operations. :const:`Inf` and :const:`NaN` propagate through complex numbers in the real -and imaginary parts of a complex number as described in the +and imaginary parts of a complex number as described in the :ref:`man-special-floats` section: .. doctest:: diff --git a/doc/manual/constructors.rst b/doc/manual/constructors.rst index afab01f0fe0d9..a6b1d069daf0f 100644 --- a/doc/manual/constructors.rst +++ b/doc/manual/constructors.rst @@ -3,7 +3,7 @@ .. currentmodule:: Base ************** - Constructors + Constructors ************** Constructors [#]_ are functions that create new objects — specifically, diff --git a/doc/manual/control-flow.rst b/doc/manual/control-flow.rst index 41666af8e3fc5..4f54219d5f139 100644 --- a/doc/manual/control-flow.rst +++ b/doc/manual/control-flow.rst @@ -121,8 +121,8 @@ blocks as desired can be used. The condition expressions in the evaluates to ``true``, after which the associated block is evaluated, and no further condition expressions or blocks are evaluated. -``if`` blocks are "leaky", i.e. they do not introduce a local scope. -This means that new variables defined inside the ``ìf`` clauses can +``if`` blocks are "leaky", i.e. they do not introduce a local scope. +This means that new variables defined inside the ``ìf`` clauses can be used after the ``if`` block, even if they weren't defined before. So, we could have defined the ``test`` function above as @@ -133,12 +133,12 @@ So, we could have defined the ``test`` function above as relation = "less than" elseif x == y relation = "equal to" - else + else relation = "greater than" end println("x is ", relation, " than y.") end - + ``if`` blocks also return a value, which may seem unintuitive to users coming from many other languages. This value is simply the return value of the last executed statement in the branch that was chosen, so @@ -146,7 +146,7 @@ of the last executed statement in the branch that was chosen, so .. doctest:: julia> x = 3 - + julia> if x > 0 "positive!" else @@ -315,7 +315,7 @@ You can easily experiment in the same way with the associativity and precedence of various combinations of ``&&`` and ``||`` operators. This behavior is frequently used in Julia to form an alternative to very short -``if`` statements. Instead of ``if end``, one can write +``if`` statements. Instead of ``if end``, one can write `` && `` (which could be read as: *and then* ). Similarly, instead of ``if ! end``, one can write `` || `` (which could be read as: *or else* ). @@ -330,13 +330,13 @@ For example, a recursive factorial routine could be defined like this: n * factorial(n-1) end factorial (generic function with 1 method) - + julia> factorial(5) 120 - + julia> factorial(0) 1 - + julia> factorial(-1) ERROR: n must be non-negative in factorial at none:2 @@ -361,7 +361,7 @@ infix operator syntax, but always evaluate their arguments: Just like condition expressions used in ``if``, ``elseif`` or the ternary operator, the operands of ``&&`` or ``||`` must be boolean -values (``true`` or ``false``). Using a non-boolean value anywhere +values (``true`` or ``false``). Using a non-boolean value anywhere except for the last entry in a conditional chain is an error: .. doctest:: @@ -369,7 +369,7 @@ except for the last entry in a conditional chain is an error: julia> 1 && true ERROR: type: non-boolean (Int64) used in boolean context -On the other hand, any type of expression can be used at the end of a conditional chain. +On the other hand, any type of expression can be used at the end of a conditional chain. It will be evaluated and returned depending on the preceding conditionals: .. testsetup:: @@ -643,10 +643,10 @@ if the argument is negative: julia> f(x) = x>=0 ? exp(-x) : throw(DomainError()) f (generic function with 1 method) - + julia> f(1) 0.36787944117144233 - + julia> f(-1) ERROR: DomainError in f at none:1 @@ -658,7 +658,7 @@ exception. It needs to be called to obtain an :exc:`Exception` object: julia> typeof(DomainError()) <: Exception true - + julia> typeof(DomainError) <: Exception false @@ -739,11 +739,11 @@ execution.: julia> info("Hi"); 1+1 INFO: Hi 2 - + julia> warn("Hi"); 1+1 WARNING: Hi 2 - + julia> error("Hi"); 1+1 ERROR: Hi in error at error.jl:21 @@ -765,10 +765,10 @@ call either the real or complex square root method on demand using sqrt(complex(x, 0)) end f (generic function with 1 method) - + julia> f(1) 1.0 - + julia> f(-1) 0.0 + 1.0im @@ -793,16 +793,16 @@ assumes ``x`` is a real number and returns its square root: end end sqrt_second (generic function with 1 method) - + julia> sqrt_second([1 4]) 2.0 - + julia> sqrt_second([1 -4]) 0.0 + 2.0im - + julia> sqrt_second(9) 3.0 - + julia> sqrt_second(-9) ERROR: DomainError in sqrt_second at none:7 diff --git a/doc/manual/conversion-and-promotion.rst b/doc/manual/conversion-and-promotion.rst index 81eec7e1f12ae..f24e36d126bb8 100644 --- a/doc/manual/conversion-and-promotion.rst +++ b/doc/manual/conversion-and-promotion.rst @@ -1,7 +1,7 @@ .. _man-conversion-and-promotion: ************************** - Conversion and Promotion + Conversion and Promotion ************************** Julia has a system for promoting arguments of mathematical operators to @@ -146,7 +146,7 @@ to zero: false The method signatures for conversion methods are often quite a bit more -involved than this example, especially for parametric types. The example +involved than this example, especially for parametric types. The example above is meant to be pedagogical, and is not the actual julia behaviour. This is the actual implementation in julia:: diff --git a/doc/manual/dates.rst b/doc/manual/dates.rst index aa109d568093d..488d1945dfc2f 100644 --- a/doc/manual/dates.rst +++ b/doc/manual/dates.rst @@ -3,7 +3,7 @@ .. currentmodule:: Base.Dates ************************************* - Date and DateTime + Date and DateTime ************************************* The :mod:`Dates` module provides two types for working with dates: :class:`Date` and :class:`DateTime`, representing day and millisecond precision, respectively; both are subtypes of the abstract :class:`TimeType`. The motivation for distinct types is simple: some operations are much simpler, both in terms of code and mental reasoning, when the complexities of greater precision don't have to be dealt with. For example, since the :class:`Date` type only resolves to the precision of a single date (i.e. no hours, minutes, or seconds), normal considerations for time zones, daylight savings/summer time, and leap seconds are unnecessary and avoided. @@ -52,11 +52,11 @@ Constructors julia> Date(Dates.Month(7),Dates.Year(2013)) 2013-07-01 -:class:`Date` or :class:`DateTime` parsing is accomplished by the use of format strings. Format strings work by the notion of defining *delimited* or *fixed-width* "slots" that contain a period to parse and pass to a :class:`Date` or :class:`DateTime` constructor. +:class:`Date` or :class:`DateTime` parsing is accomplished by the use of format strings. Format strings work by the notion of defining *delimited* or *fixed-width* "slots" that contain a period to parse and pass to a :class:`Date` or :class:`DateTime` constructor. -Delimited slots are marked by specifying the delimiter the parser should expect between two subsequent periods; so ``"y-m-d"`` lets the parser know that between the first and second slots in a date string like ``"2014-07-16"``, it should find the ``-`` character. The ``y``, ``m``, and ``d`` characters let the parser know which periods to parse in each slot. +Delimited slots are marked by specifying the delimiter the parser should expect between two subsequent periods; so ``"y-m-d"`` lets the parser know that between the first and second slots in a date string like ``"2014-07-16"``, it should find the ``-`` character. The ``y``, ``m``, and ``d`` characters let the parser know which periods to parse in each slot. -Fixed-width slots are specified by repeating the period character the number of times corresponding to the width. So ``"yyyymmdd"`` would correspond to a date string like ``"20140716"``. The parser distinguishes a fixed-width slot by the absence of a delimiter, noting the transition ``"yyyymm"`` from one period character to the next. +Fixed-width slots are specified by repeating the period character the number of times corresponding to the width. So ``"yyyymmdd"`` would correspond to a date string like ``"20140716"``. The parser distinguishes a fixed-width slot by the absence of a delimiter, noting the transition ``"yyyymm"`` from one period character to the next. Support for text-form month parsing is also supported through the ``u`` and ``U`` characters, for abbreviated and full-length month names, respectively. By default, only English month names are supported, so ``u`` corresponds to "Jan", "Feb", "Mar", etc. And ``U`` corresponds to "January", "February", "March", etc. Similar to other name=>value mapping functions :func:`dayname` and :func:`monthname`, custom locales can be loaded by passing in the ``locale=>Dict{UTF8String,Int}`` mapping to the :const:`MONTHTOVALUEABBR` and :const:`MONTHTOVALUE` dicts for abbreviated and full-name month names, respectively. @@ -160,9 +160,9 @@ Compound methods are provided, as they provide a measure of efficiency if multip One may also access the underlying ``UTInstant`` or integer value:: julia> dump(t) - Date - instant: UTInstant{Day} - periods: Day + Date + instant: UTInstant{Day} + periods: Day value: Int64 735264 julia> t.instant @@ -259,7 +259,7 @@ The :mod:`Dates` module provides the *adjuster* API through several convenient m # Adjusts the input to the Monday of the input's week julia> Dates.firstdayofweek(Date(2014,7,16)) - 2014-07-14 + 2014-07-14 # Adjusts to the last day of the input's month julia> Dates.lastdayofmonth(Date(2014,7,16)) @@ -269,7 +269,7 @@ The :mod:`Dates` module provides the *adjuster* API through several convenient m julia> Dates.lastdayofquarter(Date(2014,7,16)) 2014-09-30 -The next two higher-order methods, :func:`tonext`, and :func:`toprev`, generalize working with temporal expressions by taking a :class:`DateFunction` as first argument, along with a starting :class:`TimeType`. A :class:`DateFunction` is just a function, usually anonymous, that takes a single :class:`TimeType` as input and returns a ``Bool``, ``true`` indicating a satisfied adjustment criterion. +The next two higher-order methods, :func:`tonext`, and :func:`toprev`, generalize working with temporal expressions by taking a :class:`DateFunction` as first argument, along with a starting :class:`TimeType`. A :class:`DateFunction` is just a function, usually anonymous, that takes a single :class:`TimeType` as input and returns a ``Bool``, ``true`` indicating a satisfied adjustment criterion. For example:: julia> istuesday = x->Dates.dayofweek(x) == Dates.Tuesday # Returns true if the day of the week of x is Tuesday @@ -300,7 +300,7 @@ The final method in the adjuster API is the :func:`recur` function. :func:`recur # Date range from January 1st, 2014 to January 1st, 2015 julia> dr = Dates.Date(2014):Dates.Date(2015); julia> recur(dr) do x - Dates.dayofweek(x) == Dates.Tue && + Dates.dayofweek(x) == Dates.Tue && Dates.April <= Dates.month(x) <= Dates.Nov && Dates.dayofweekofmonth(x) == 2 end diff --git a/doc/manual/embedding.rst b/doc/manual/embedding.rst index fc6085429b221..31d590f07201e 100644 --- a/doc/manual/embedding.rst +++ b/doc/manual/embedding.rst @@ -138,18 +138,18 @@ Alternatively, if you have already allocated the array you can generate a thin w double *existingArray = (double*)malloc(sizeof(double)*10); jl_array_t *x = jl_ptr_to_array_1d(array_type, existingArray, 10, 0); - + The last argument is a boolean indicating whether Julia should take ownership of the data. If this argument is non-zero, the GC will call ``free`` on the data pointer when the array is no longer referenced. In order to access the data of x, we can use ``jl_array_data``:: double *xData = (double*)jl_array_data(x); - + Now we can fill the array:: for(size_t i=0; i ~/.juliarc.jl $ julia Greetings! 你好! 안녕하세요? - + ... .. raw:: latex @@ -116,7 +116,7 @@ those available for the ``perl`` and ``ruby`` programs:: -p Run n local processes --machinefile Run processes on hosts listed in - + -i Force isinteractive() to be true --no-history-file Don't load or save history -f, --no-startup Don't load ~/.juliarc.jl @@ -124,7 +124,7 @@ those available for the ``perl`` and ``ruby`` programs:: --color={yes|no} Enable or disable color text --compile={yes|no|all} Enable or disable compiler, or request exhaustive compilation - + --code-coverage={none|user|all}, --code-coverage Count executions of source lines (omitting setting is equivalent to 'user') --track-allocation={none|user|all} diff --git a/doc/manual/integers-and-floating-point-numbers.rst b/doc/manual/integers-and-floating-point-numbers.rst index 6585c4f813892..703efb2a399bf 100644 --- a/doc/manual/integers-and-floating-point-numbers.rst +++ b/doc/manual/integers-and-floating-point-numbers.rst @@ -3,7 +3,7 @@ .. currentmodule:: Base ************************************* - Integers and Floating-Point Numbers + Integers and Floating-Point Numbers ************************************* Integers and floating-point values are the basic building blocks of @@ -97,7 +97,7 @@ is 32-bit or 64-bit.:: # 64-bit system: julia> WORD_SIZE 64 - + Julia also defines the types :class:`Int` and :class:`UInt`, which are aliases for the system's signed and unsigned native integer types respectively.:: @@ -217,7 +217,7 @@ a wraparound behavior: julia> x = typemax(Int64) 9223372036854775807 - + julia> x + 1 -9223372036854775808 @@ -338,10 +338,10 @@ be seen using the ``bits`` function: : julia> 0.0 == -0.0 true - + julia> bits(0.0) "0000000000000000000000000000000000000000000000000000000000000000" - + julia> bits(-0.0) "1000000000000000000000000000000000000000000000000000000000000000" @@ -354,7 +354,7 @@ There are three specified standard floating-point values that do not correspond to any point on the real number line: =========== =========== =========== ================= ================================================================= -Special value Name Description +Special value Name Description ----------------------------------- ----------------- ----------------------------------------------------------------- ``Float16`` ``Float32`` ``Float64`` =========== =========== =========== ================= ================================================================= @@ -481,19 +481,19 @@ argument respectively: : julia> x = 1.25f0 1.25f0 - + julia> nextfloat(x) 1.2500001f0 - + julia> prevfloat(x) 1.2499999f0 - + julia> bits(prevfloat(x)) "00111111100111111111111111111111" - + julia> bits(x) "00111111101000000000000000000000" - + julia> bits(nextfloat(x)) "00111111101000000000000000000001" @@ -507,7 +507,7 @@ If a number doesn't have an exact floating-point representation, it must be rounded to an appropriate representable value, however, if wanted, the manner in which this rounding is done can be changed according to the rounding modes presented in the `IEEE 754 standard `_:: - + julia> 1.1 + 0.1 1.2000000000000002 @@ -560,13 +560,13 @@ computation, and also in the following references: Arbitrary Precision Arithmetic ------------------------------ -To allow computations with arbitrary-precision integers and floating point numbers, -Julia wraps the `GNU Multiple Precision Arithmetic Library (GMP) `_ and the `GNU MPFR Library `_, respectively. -The :class:`BigInt` and :class:`BigFloat` types are available in Julia for arbitrary precision -integer and floating point numbers respectively. +To allow computations with arbitrary-precision integers and floating point numbers, +Julia wraps the `GNU Multiple Precision Arithmetic Library (GMP) `_ and the `GNU MPFR Library `_, respectively. +The :class:`BigInt` and :class:`BigFloat` types are available in Julia for arbitrary precision +integer and floating point numbers respectively. -Constructors exist to create these types from primitive numerical types, or from :class:`AbstractString`. -Once created, they participate in arithmetic with all other numeric types thanks to Julia's +Constructors exist to create these types from primitive numerical types, or from :class:`AbstractString`. +Once created, they participate in arithmetic with all other numeric types thanks to Julia's :ref:`type promotion and conversion mechanism `. : .. doctest:: @@ -593,19 +593,19 @@ However, type promotion between the primitive types above and julia> x = typemin(Int64) -9223372036854775808 - + julia> x = x - 1 9223372036854775807 - + julia> typeof(x) Int64 julia> y = BigInt(typemin(Int64)) -9223372036854775808 - + julia> y = y - 1 -9223372036854775809 - + julia> typeof(y) BigInt (constructor with 10 methods) @@ -751,7 +751,7 @@ Examples: julia> zero(Float32) 0.0f0 - + julia> zero(1.0) 0.0 diff --git a/doc/manual/interacting-with-julia.rst b/doc/manual/interacting-with-julia.rst index f70ae683f2089..1331525fbc0ca 100644 --- a/doc/manual/interacting-with-julia.rst +++ b/doc/manual/interacting-with-julia.rst @@ -1,7 +1,7 @@ .. _man-interacting-with-julia: ************************ - Interacting With Julia + Interacting With Julia ************************ Julia comes with a full-featured interactive command-line REPL (read-eval-print loop) built into the ``julia`` executable. In addition to allowing quick and easy evaluation of Julia statements, it has a searchable history, tab-completion, many helpful keybindings, and dedicated help and shell modes. The REPL can be started by simply calling julia with no arguments or double-clicking on the executable:: @@ -16,9 +16,9 @@ Julia comes with a full-featured interactive command-line REPL (read-eval-print _/ |\__'_|_|_|\__'_| | Commit 64f437b (0 days old master) |__/ | x86_64-apple-darwin13.1.0 - julia> + julia> -To exit the interactive session, type ``^D`` — the control key together with the ``d`` key on a blank line — or type ``quit()`` followed by the return or enter key. The REPL greets you with a banner and a ``julia>`` prompt. +To exit the interactive session, type ``^D`` — the control key together with the ``d`` key on a blank line — or type ``quit()`` followed by the return or enter key. The REPL greets you with a banner and a ``julia>`` prompt. The different prompt modes -------------------------- @@ -38,7 +38,7 @@ There are a number useful features unique to interactive work. In addition to sh .. doctest:: julia> string(3 * 4); - + julia> ans "12" @@ -47,8 +47,8 @@ Help mode When the cursor is at the beginning of the line, the prompt can be changed to a help mode by typing ``?``. Julia will attempt to print help or documentation for anything entered in help mode:: - julia> ? # upon typing ?, the prompt changes (in place) to: help> - + julia> ? # upon typing ?, the prompt changes (in place) to: help> + help> string Base.string(xs...) @@ -58,7 +58,7 @@ In addition to function names, complete function calls may be entered to see whi help> string(1) string(x::Union(Int16,Int128,Int8,Int32,Int64)) at string.jl:1553 - + help> @printf Base.@printf([io::IOStream], "%Fmt", args...) @@ -80,8 +80,8 @@ Just as help mode is useful for quick access to documentation, another common ta :: - julia> ; # upon typing ;, the prompt changes (in place) to: shell> - + julia> ; # upon typing ;, the prompt changes (in place) to: shell> + shell> echo hello hello diff --git a/doc/manual/introduction.rst b/doc/manual/introduction.rst index af138a23a6b01..bb6f5290262e6 100644 --- a/doc/manual/introduction.rst +++ b/doc/manual/introduction.rst @@ -1,7 +1,7 @@ .. _man-introduction: ************** - Introduction + Introduction ************** Scientific computing has traditionally required the highest performance, @@ -20,7 +20,7 @@ Because Julia's compiler is different from the interpreters used for languages like Python or R, you may find that Julia's performance is unintuitive at first. If you find that something is slow, we highly recommend reading through the :ref:`man-performance-tips` -section before trying anything else. Once you understand how Julia +section before trying anything else. Once you understand how Julia works, it's easy to write code that's nearly as fast as C. Julia features optional typing, multiple dispatch, and good diff --git a/doc/manual/linear-algebra.rst b/doc/manual/linear-algebra.rst index d7942b65cac68..5769a26ef25bb 100644 --- a/doc/manual/linear-algebra.rst +++ b/doc/manual/linear-algebra.rst @@ -1,7 +1,7 @@ .. currentmodule:: Base **************** - Linear algebra + Linear algebra **************** Matrix factorizations @@ -30,7 +30,7 @@ in the :ref:`stdlib-linalg` section of the standard library documentation. :class:`GeneralizedSVD` `Generalized SVD `_ ======================== ====== -Special matrices +Special matrices ================ `Matrices with special symmetries and structures `_ diff --git a/doc/manual/mathematical-operations.rst b/doc/manual/mathematical-operations.rst index e025d5e633233..c8cf53c86b5e8 100644 --- a/doc/manual/mathematical-operations.rst +++ b/doc/manual/mathematical-operations.rst @@ -3,7 +3,7 @@ .. currentmodule:: Base ************************************************** - Mathematical Operations and Elementary Functions + Mathematical Operations and Elementary Functions ************************************************** Julia provides a complete collection of basic arithmetic and bitwise @@ -68,7 +68,7 @@ operators `_ are supported on all primitive integer types: =========== ========================================================================= -Expression Name +Expression Name =========== ========================================================================= ``~x`` bitwise not ``x & y`` bitwise and @@ -127,7 +127,7 @@ are:: .. note:: An updating operator rebinds the variable on the left-hand side. As a result, the type of the variable may change. - + .. doctest:: julia> x = 0x01; typeof(x) @@ -135,7 +135,7 @@ are:: julia> x *= 2 #Same as x = x * 2 2 - + julia> isa(x, Int) true @@ -250,7 +250,7 @@ Function Tests if julia> isequal([1 NaN], [1 NaN]) true - + julia> isequal(NaN,NaN32) true @@ -329,7 +329,7 @@ be used explicitly (see :ref:`man-short-circuit-evaluation`). Operator Precedence ~~~~~~~~~~~~~~~~~~~ -Julia applies the following order of operations, from highest precedence +Julia applies the following order of operations, from highest precedence to lowest: ================= ============================================================================================= @@ -482,28 +482,28 @@ Function Description :func:`lbeta(x,y) ` accurate ``log(beta(x,y))`` for large ``x`` or ``y`` :func:`eta(x) ` `Dirichlet eta function `_ at ``x`` :func:`zeta(x) ` `Riemann zeta function `_ at ``x`` -|airylist| `Airy Ai function `_ at ``z`` -|airyprimelist| derivative of the Airy Ai function at ``z`` -:func:`airybi(z) `, ``airy(2,z)`` `Airy Bi function `_ at ``z`` -:func:`airybiprime(z) `, ``airy(3,z)`` derivative of the Airy Bi function at ``z`` -:func:`airyx(z) `, ``airyx(k,z)`` scaled Airy AI function and ``k`` th derivatives at ``z`` -:func:`besselj(nu,z) ` `Bessel function `_ of the first kind of order ``nu`` at ``z`` -:func:`besselj0(z) ` ``besselj(0,z)`` -:func:`besselj1(z) ` ``besselj(1,z)`` -:func:`besseljx(nu,z) ` scaled Bessel function of the first kind of order ``nu`` at ``z`` -:func:`bessely(nu,z) ` `Bessel function `_ of the second kind of order ``nu`` at ``z`` -:func:`bessely0(z) ` ``bessely(0,z)`` -:func:`bessely1(z) ` ``bessely(1,z)`` -:func:`besselyx(nu,z) ` scaled Bessel function of the second kind of order ``nu`` at ``z`` -:func:`besselh(nu,k,z) ` `Bessel function `_ of the third kind (a.k.a. Hankel function) of order ``nu`` at ``z``; ``k`` must be either ``1`` or ``2`` -:func:`hankelh1(nu,z) ` ``besselh(nu, 1, z)`` -:func:`hankelh1x(nu,z) ` scaled ``besselh(nu, 1, z)`` -:func:`hankelh2(nu,z) ` ``besselh(nu, 2, z)`` -:func:`hankelh2x(nu,z) ` scaled ``besselh(nu, 2, z)`` -:func:`besseli(nu,z) ` modified `Bessel function `_ of the first kind of order ``nu`` at ``z`` -:func:`besselix(nu,z) ` scaled modified Bessel function of the first kind of order ``nu`` at ``z`` -:func:`besselk(nu,z) ` modified `Bessel function `_ of the second kind of order ``nu`` at ``z`` -:func:`besselkx(nu,z) ` scaled modified Bessel function of the second kind of order ``nu`` at ``z`` +|airylist| `Airy Ai function `_ at ``z`` +|airyprimelist| derivative of the Airy Ai function at ``z`` +:func:`airybi(z) `, ``airy(2,z)`` `Airy Bi function `_ at ``z`` +:func:`airybiprime(z) `, ``airy(3,z)`` derivative of the Airy Bi function at ``z`` +:func:`airyx(z) `, ``airyx(k,z)`` scaled Airy AI function and ``k`` th derivatives at ``z`` +:func:`besselj(nu,z) ` `Bessel function `_ of the first kind of order ``nu`` at ``z`` +:func:`besselj0(z) ` ``besselj(0,z)`` +:func:`besselj1(z) ` ``besselj(1,z)`` +:func:`besseljx(nu,z) ` scaled Bessel function of the first kind of order ``nu`` at ``z`` +:func:`bessely(nu,z) ` `Bessel function `_ of the second kind of order ``nu`` at ``z`` +:func:`bessely0(z) ` ``bessely(0,z)`` +:func:`bessely1(z) ` ``bessely(1,z)`` +:func:`besselyx(nu,z) ` scaled Bessel function of the second kind of order ``nu`` at ``z`` +:func:`besselh(nu,k,z) ` `Bessel function `_ of the third kind (a.k.a. Hankel function) of order ``nu`` at ``z``; ``k`` must be either ``1`` or ``2`` +:func:`hankelh1(nu,z) ` ``besselh(nu, 1, z)`` +:func:`hankelh1x(nu,z) ` scaled ``besselh(nu, 1, z)`` +:func:`hankelh2(nu,z) ` ``besselh(nu, 2, z)`` +:func:`hankelh2x(nu,z) ` scaled ``besselh(nu, 2, z)`` +:func:`besseli(nu,z) ` modified `Bessel function `_ of the first kind of order ``nu`` at ``z`` +:func:`besselix(nu,z) ` scaled modified Bessel function of the first kind of order ``nu`` at ``z`` +:func:`besselk(nu,z) ` modified `Bessel function `_ of the second kind of order ``nu`` at ``z`` +:func:`besselkx(nu,z) ` scaled modified Bessel function of the second kind of order ``nu`` at ``z`` =================================================== ============================================================================== .. |airylist| replace:: :func:`airy(z) `, :func:`airyai(z) `, ``airy(0,z)`` diff --git a/doc/manual/methods.rst b/doc/manual/methods.rst index 8da8b9d290c53..9828fbfb62685 100644 --- a/doc/manual/methods.rst +++ b/doc/manual/methods.rst @@ -1,7 +1,7 @@ .. _man-methods: ********* - Methods + Methods ********* Recall from :ref:`man-functions` that a function is an object @@ -363,11 +363,11 @@ arguments: julia> g(x::Float64, y) = 2x + y; julia> g(x, y::Float64) = x + 2y; - Warning: New definition + Warning: New definition g(Any,Float64) at none:1 - is ambiguous with: + is ambiguous with: g(Float64,Any) at none:1. - To fix, define + To fix, define g(Float64,Float64) before the new definition. diff --git a/doc/manual/modules.rst b/doc/manual/modules.rst index bb1bbc0997812..7bf9f2f57c3c0 100644 --- a/doc/manual/modules.rst +++ b/doc/manual/modules.rst @@ -1,7 +1,7 @@ .. _man-modules: ********* - Modules + Modules ********* .. index:: module, baremodule, using, import, export, importall @@ -13,27 +13,27 @@ when your code is used together with somebody else's. Within a module, you can control which names from other modules are visible (via importing), and specify which of your names are intended to be public (via exporting). -The following example demonstrates the major features of modules. It is +The following example demonstrates the major features of modules. It is not meant to be run, but is shown for illustrative purposes:: module MyModule using Lib - + using BigLib: thing1, thing2 import Base.show importall OtherLib - + export MyType, foo - + type MyType x end - + bar(x) = 2x foo(a::MyType) = bar(a.x) + 1 - + show(io, a::MyType) = print(io, "MyType $(a.x)") end @@ -80,13 +80,13 @@ Summary of module usage To load a module, two main keywords can be used: ``using`` and ``import``. To understand their differences, consider the following example:: module MyModule - + export x, y x() = "x" y() = "y" p() = "p" - + end In this module we export the ``x`` and ``y`` functions (with the keyword ``export``), and also have the non-exported function ``p``. There are several different ways to load the Module and its inner functions into the current workspace: @@ -281,7 +281,7 @@ functions of external C libraries and initializing global constants that involve pointers returned by external libraries. For example, suppose that we are calling a C library ``libfoo`` that requires us to call a ``foo_init()`` initialization function at runtime. Suppose -that we also want to define a global constant ``foo_data_ptr`` that +that we also want to define a global constant ``foo_data_ptr`` that holds the return value of a ``void *foo_data()`` function defined by ``libfoo`` — this constant must be initialized at runtime (not at compile time) because the pointer address will change from run to run. You diff --git a/doc/manual/networking-and-streams.rst b/doc/manual/networking-and-streams.rst index bac3da8224c15..f0ef76174da54 100644 --- a/doc/manual/networking-and-streams.rst +++ b/doc/manual/networking-and-streams.rst @@ -3,14 +3,14 @@ .. currentmodule:: Base ************************ - Networking and Streams + Networking and Streams ************************ Julia provides a rich interface to deal with streaming I/O objects such as -terminals, pipes and TCP sockets. This interface, though asynchronous at the +terminals, pipes and TCP sockets. This interface, though asynchronous at the system level, is presented in a synchronous manner to the programmer and it is -usually unnecessary to think about the underlying asynchronous operation. This -is achieved by making heavy use of Julia cooperative threading (:ref:`coroutine `) +usually unnecessary to think about the underlying asynchronous operation. This +is achieved by making heavy use of Julia cooperative threading (:ref:`coroutine `) functionality. Basic Stream I/O @@ -20,7 +20,7 @@ All Julia streams expose at least a :func:`read` and a :func:`write` method, tak julia> write(STDOUT,"Hello World") Hello World - + julia> read(STDIN,Char) '\n' @@ -37,7 +37,7 @@ data to be read as the second argument. For example, to read a simple byte array 0x00 julia> read!(STDIN,x) - abcd + abcd 4-element Array{UInt8,1}: 0x61 0x62 @@ -46,14 +46,14 @@ data to be read as the second argument. For example, to read a simple byte array However, since this is slightly cumbersome, there are several convenience methods provided. For example, we could have written the above as:: - + julia> readbytes(STDIN,4) - abcd + abcd 4-element Array{UInt8,1}: 0x61 0x62 0x63 - 0x64 + 0x64 or if we had wanted to read the entire line instead:: @@ -80,9 +80,9 @@ or :func:`read` if you wanted to read by character instead:: Text I/O -------- -Note that the write method mentioned above operates on binary streams. In particular, values do not get converted to any canonical text +Note that the write method mentioned above operates on binary streams. In particular, values do not get converted to any canonical text representation but are written out as is:: - + julia> write(STDOUT,0x61) a @@ -91,7 +91,7 @@ the difference between the two):: julia> print(STDOUT,0x61) 97 - + Working with Files ------------------ @@ -105,20 +105,20 @@ are ``Hello, World!``:: julia> readlines(f) 1-element Array{Union(ASCIIString,UTF8String),1}: "Hello, World!\n" - + If you want to write to a file, you can open it with the write (``"w"``) flag:: julia> f = open("hello.txt","w") IOStream() - + julia> write(f,"Hello again.") 12 - + If you examine the contents of ``hello.txt`` at this point, you will notice that it is empty; nothing has actually been written to disk yet. This is because the :class:`IOStream` must be closed before the write is actually flushed to disk:: julia> close(f) - + Examining ``hello.txt`` again will show its contents have been changed. Opening a file, doing something to its contents, and closing it again is a very common pattern. @@ -129,12 +129,12 @@ an argument, and then closes it again. For example, given a function:: function read_and_capitalize(f::IOStream) return uppercase(readall(f)) end - + You can call:: julia> open(read_and_capitalize, "hello.txt") "HELLO AGAIN." - + to open ``hello.txt``, call ``read_and_capitalize on it``, close ``hello.txt`` and return the capitalized contents. To avoid even having to define a named function, you can use the ``do`` syntax, which creates an anonymous @@ -149,7 +149,7 @@ function on the fly:: A simple TCP example -------------------- -Let's jump right in with a simple example involving TCP sockets. Let's first create a simple server:: +Let's jump right in with a simple example involving TCP sockets. Let's first create a simple server:: julia> @async begin server = listen(2000) @@ -162,12 +162,12 @@ Let's jump right in with a simple example involving TCP sockets. Let's first cre julia> -To those familiar with the Unix socket API, the method names will feel familiar, +To those familiar with the Unix socket API, the method names will feel familiar, though their usage is somewhat simpler than the raw Unix socket API. The first -call to :func:`listen` will create a server waiting for incoming connections on the -specified port (2000) in this case. The same function may also be used to +call to :func:`listen` will create a server waiting for incoming connections on the +specified port (2000) in this case. The same function may also be used to create various other kinds of servers:: - + julia> listen(2000) # Listens on localhost:2000 (IPv4) TcpServer(active) @@ -186,26 +186,26 @@ create various other kinds of servers:: julia> listen("testsocket") # Listens on a domain socket/named pipe PipeServer(active) -Note that the return type of the last invocation is different. This is because -this server does not listen on TCP, but rather on a named pipe (Windows) -or domain socket (UNIX). The difference +Note that the return type of the last invocation is different. This is because +this server does not listen on TCP, but rather on a named pipe (Windows) +or domain socket (UNIX). The difference is subtle and has to do with the :func:`accept` and :func:`connect` methods. The :func:`accept` method retrieves a connection to the client that is connecting on the server we -just created, while the :func:`connect` function connects to a server using the -specified method. The :func:`connect` function takes the same arguments as -:func:`listen`, so, assuming the environment (i.e. host, cwd, etc.) is the same you -should be able to pass the same arguments to :func:`connect` as you did to listen to +just created, while the :func:`connect` function connects to a server using the +specified method. The :func:`connect` function takes the same arguments as +:func:`listen`, so, assuming the environment (i.e. host, cwd, etc.) is the same you +should be able to pass the same arguments to :func:`connect` as you did to listen to establish the connection. So let's try that out (after having created the server above):: - + julia> connect(2000) TcpSocket(open, 0 bytes waiting) julia> Hello World -As expected we saw "Hello World" printed. So, let's actually analyze what happened behind the scenes. When we called :func:`connect`, we connect to the server we had just created. Meanwhile, the accept function returns a server-side connection to the newly created socket and prints "Hello World" to indicate that the connection was successful. +As expected we saw "Hello World" printed. So, let's actually analyze what happened behind the scenes. When we called :func:`connect`, we connect to the server we had just created. Meanwhile, the accept function returns a server-side connection to the newly created socket and prints "Hello World" to indicate that the connection was successful. A great strength of Julia is that since the API is exposed synchronously even though the I/O is actually happening asynchronously, we didn't have to worry callbacks or even making sure that the server gets to run. When we called :func:`connect` the current task waited for the connection to be established and only continued executing after that was done. In this pause, the server task resumed execution (because a connection request was now available), accepted the connection, printed the message and waited for the next client. Reading and writing works in the same way. To see this, consider the following simple echo server:: - + julia> @async begin server = listen(2001) while true @@ -235,15 +235,15 @@ As with other streams, use :func:`close` to disconnect the socket:: Resolving IP Addresses ---------------------- -One of the :func:`connect` methods that does not follow the :func:`listen` methods is ``connect(host::ASCIIString,port)``, which will attempt to connect to the host -given by the ``host`` parameter on the port given by the port parameter. It +One of the :func:`connect` methods that does not follow the :func:`listen` methods is ``connect(host::ASCIIString,port)``, which will attempt to connect to the host +given by the ``host`` parameter on the port given by the port parameter. It allows you to do things like:: - + julia> connect("google.com",80) TcpSocket(open, 0 bytes waiting) At the base of this functionality is :func:`getaddrinfo`, which will do the appropriate address resolution:: - + julia> getaddrinfo("google.com") IPv4(74.125.226.225) diff --git a/doc/manual/packages.rst b/doc/manual/packages.rst index 28cb226e93256..56a16e439f3be 100644 --- a/doc/manual/packages.rst +++ b/doc/manual/packages.rst @@ -360,13 +360,13 @@ not domain experts*. * Julia does not have a single comprehensive plotting package. Instead, ``Gadfly``, ``PyPlot``, ``Winston`` and other packages each implement a unique approach based on a particular design philosophy. - + * In contrast, ``SortingAlgorithms`` provides a consistent interface to use many well-established sorting algorithms. 5. Packages that wrap external libraries or programs should be named after those libraries or programs. - + * ``CPLEX.jl`` wraps the ``CPLEX`` library, which can be identified easily in a web search. @@ -518,11 +518,11 @@ that copy exists, you can push your local changes to your copy 1. go to ``_ and create your own fork. - + 2. add your fork as a remote repository for the METADATA repository on your local computer (in the terminal where USERNAME is your github username):: - + cd ~/.julia/METADATA git remote add USERNAME https://github.com/USERNAME/METADATA.jl.git diff --git a/doc/manual/performance-tips.rst b/doc/manual/performance-tips.rst index 03f6259b99231..8186a9da43da5 100644 --- a/doc/manual/performance-tips.rst +++ b/doc/manual/performance-tips.rst @@ -654,7 +654,7 @@ evaluates the L2-norm of the result:: u[i] = sin(2pi*dx*i) end end - + function deriv!(u, du) n = length(u) dx = 1.0 / (n-1) @@ -664,7 +664,7 @@ evaluates the L2-norm of the result:: end @fastmath @inbounds du[n] = (u[n] - u[n-1]) / dx end - + function norm(u) n = length(u) T = eltype(u) @@ -674,24 +674,24 @@ evaluates the L2-norm of the result:: end @fastmath @inbounds return sqrt(s/n) end - + function main() n = 2000 u = Array(Float64, n) init!(u) du = similar(u) - + deriv!(u, du) nu = norm(du) - + @time for i in 1:10^6 deriv!(u, du) nu = norm(du) end - + println(nu) end - + main() On a computer with a 2.7 GHz Intel Core i7 processor, this produces:: diff --git a/doc/manual/running-external-programs.rst b/doc/manual/running-external-programs.rst index f89e40132071f..a5278324a566f 100644 --- a/doc/manual/running-external-programs.rst +++ b/doc/manual/running-external-programs.rst @@ -3,7 +3,7 @@ .. currentmodule:: Base *************************** - Running External Programs + Running External Programs *************************** Julia borrows backtick notation for commands from the shell, Perl, and @@ -36,9 +36,9 @@ Here's a simple example of running an external program:: julia> run(`echo hello`) hello -The ``hello`` is the output of the ``echo`` command, sent to :const:`STDOUT`. +The ``hello`` is the output of the ``echo`` command, sent to :const:`STDOUT`. The run method itself returns ``nothing``, and throws an :exc:`ErrorException` -if the external command fails to run successfully. +if the external command fails to run successfully. If you want to read the output of the external command, :func:`readall` can be used instead:: @@ -111,7 +111,7 @@ case, just use an array (or any other iterable container):: julia> files = ["/etc/passwd","/Volumes/External HD/data.csv"] 2-element ASCIIString Array: - "/etc/passwd" + "/etc/passwd" "/Volumes/External HD/data.csv" diff --git a/doc/manual/strings.rst b/doc/manual/strings.rst index 6d710ef39f946..b129e4b72d274 100644 --- a/doc/manual/strings.rst +++ b/doc/manual/strings.rst @@ -411,7 +411,7 @@ can interpolate any expression into a string using parentheses: julia> "1 + 2 = $(1 + 2)" "1 + 2 = 3" -Both concatenation and string interpolation call +Both concatenation and string interpolation call :func:`string` to convert objects into string form. Most non-:obj:`AbstractString` objects are converted to strings closely corresponding to how they are entered as literal expressions: diff --git a/doc/manual/unicode-input.rst b/doc/manual/unicode-input.rst index 8b1b05a5bdf38..2bcd8bce4035e 100644 --- a/doc/manual/unicode-input.rst +++ b/doc/manual/unicode-input.rst @@ -1,7 +1,7 @@ .. _man-unicode-input: *************** - Unicode Input + Unicode Input *************** .. only:: html diff --git a/doc/manual/variables-and-scoping.rst b/doc/manual/variables-and-scoping.rst index 2790150ff19c1..1998fe582d8f8 100644 --- a/doc/manual/variables-and-scoping.rst +++ b/doc/manual/variables-and-scoping.rst @@ -213,16 +213,16 @@ Multiple variables can be declared global using the following syntax:: function foo() global x=1, y="bar", z=3 end - + julia> foo() 3 - + julia> x 1 - + julia> y "bar" - + julia> z 3 diff --git a/doc/manual/variables.rst b/doc/manual/variables.rst index 0f1fa2fb870e7..665b4807c493e 100644 --- a/doc/manual/variables.rst +++ b/doc/manual/variables.rst @@ -8,17 +8,17 @@ A variable, in Julia, is a name associated (or bound) to a value. It's useful wh .. doctest:: # Assign the value 10 to the variable x - julia> x = 10 + julia> x = 10 10 - + # Doing math with x's value julia> x + 1 11 - + # Reassign x's value - julia> x = 1 + 1 + julia> x = 1 + 1 2 - + # You can assign values of other types, like strings of text julia> x = "Hello World!" "Hello World!" @@ -63,7 +63,7 @@ Unicode names (in UTF-8 encoding) are allowed: julia> δ = 0.00001 1.0e-5 - julia> 안녕하세요 = "Hello" + julia> 안녕하세요 = "Hello" "Hello" In the Julia REPL and several other Julia editing environments, you @@ -82,21 +82,21 @@ Julia will even let you redefine built-in constants and functions if needed: julia> pi π = 3.1415926535897... - + julia> pi = 3 Warning: imported binding for pi overwritten in module Main 3 - + julia> pi 3 - + julia> sqrt(100) 10.0 - + julia> sqrt = 4 Warning: imported binding for sqrt overwritten in module Main 4 - + However, this is obviously not recommended to avoid potential confusion. Allowed Variable Names @@ -128,7 +128,7 @@ statements: julia> else = false ERROR: syntax: unexpected "else" - + julia> try = "No" ERROR: syntax: unexpected "=" @@ -146,7 +146,7 @@ adopt the following conventions: shown with upper camel case instead of underscores. - Names of ``function``\ s and ``macro``\s are in lower case, without underscores. -- Functions that write to their arguments have names that end in ``!``. +- Functions that write to their arguments have names that end in ``!``. These are sometimes called "mutating" or "in-place" functions because they are intended to produce changes in their arguments after the function is called, not just return a value. diff --git a/doc/stdlib/collections.rst b/doc/stdlib/collections.rst index c5c80e241b6a4..3d2197a963400 100644 --- a/doc/stdlib/collections.rst +++ b/doc/stdlib/collections.rst @@ -418,7 +418,7 @@ Iterable Collections 14 The associativity of the reduction is implementation-dependent. Use - :func:`mapfoldl` or :func:`mapfoldr` instead for guaranteed left or + :func:`mapfoldl` or :func:`mapfoldr` instead for guaranteed left or right associativity. .. function:: mapreduce(f, op, itr) diff --git a/doc/stdlib/dates.rst b/doc/stdlib/dates.rst index 293576845d9ed..b76c30872ddaa 100644 --- a/doc/stdlib/dates.rst +++ b/doc/stdlib/dates.rst @@ -16,13 +16,13 @@ Dates and Time Types .. data:: Minute .. data:: Second .. data:: Millisecond - + ``Period`` types represent discrete, human representations of time. .. data:: Instant ``Instant`` types represent integer-based, machine representations of time as continuous timelines starting from an epoch. - + .. data:: UTInstant{T} The ``UTInstant`` represents a machine timeline based on `UT` time (1 day = one revolution of the earth). The ``{T}`` is a ``Period`` parameter that indicates the resolution or precision of the instant. @@ -30,11 +30,11 @@ Dates and Time Types .. data:: TimeType ``TimeType`` types wrap ``Instant`` machine instances to provide human representations of the machine instant. - + .. data:: DateTime ``DateTime`` wraps a ``UTInstant{Millisecond}`` and interprets it according to the proleptic Gregorian calendar. - + .. data:: Date ``Date`` wraps a ``UTInstant{Day}`` and interprets it according to the proleptic Gregorian calendar. @@ -59,7 +59,7 @@ alternatively, you could call ``using Dates`` to bring all exported functions in .. function:: DateTime(f::Function, y[, m, d, h, mi, s]; step=Day(1), negate=false, limit=10000) -> DateTime - Create a DateTime through the adjuster API. The starting point will be constructed from the + Create a DateTime through the adjuster API. The starting point will be constructed from the provided ``y, m, d...`` arguments, and will be adjusted until ``f::Function`` returns true. The step size in adjusting can be provided manually through the ``step`` keyword. If ``negate=true``, then the adjusting will stop when ``f::Function`` returns false instead of true. ``limit`` provides a limit to @@ -109,7 +109,7 @@ alternatively, you could call ``using Dates`` to bring all exported functions in .. function:: Date(f::Function, y[, m]; step=Day(1), negate=false, limit=10000) -> Date - Create a Date through the adjuster API. The starting point will be constructed from the + Create a Date through the adjuster API. The starting point will be constructed from the provided ``y, m`` arguments, and will be adjusted until ``f::Function`` returns true. The step size in adjusting can be provided manually through the ``step`` keyword. If ``negate=true``, then the adjusting will stop when ``f::Function`` returns false instead of true. ``limit`` provides a limit to @@ -132,10 +132,10 @@ alternatively, you could call ``using Dates`` to bring all exported functions in time including the system timezone locale. .. function:: now(::Type{UTC}) -> DateTime - + Returns a DateTime corresponding to the user's system time as UTC/GMT. - + Accessor Functions ~~~~~~~~~~~~~~~~~~ @@ -215,7 +215,7 @@ Query Functions Returns the number of days in the month of ``dt``. Value will be 28, 29, 30, or 31. -.. function:: isleapyear(dt::TimeType) -> Bool +.. function:: isleapyear(dt::TimeType) -> Bool Returns true if the year of ``dt`` is a leap year. @@ -277,13 +277,13 @@ Adjuster Functions .. function:: tonext(dt::TimeType,dow::Int;same::Bool=false) -> TimeType - Adjusts ``dt`` to the next day of week corresponding to ``dow`` with + Adjusts ``dt`` to the next day of week corresponding to ``dow`` with ``1 = Monday, 2 = Tuesday, etc``. Setting ``same=true`` allows the current ``dt`` to be considered as the next ``dow``, allowing for no adjustment to occur. .. function:: toprev(dt::TimeType,dow::Int;same::Bool=false) -> TimeType - Adjusts ``dt`` to the previous day of week corresponding to ``dow`` with + Adjusts ``dt`` to the previous day of week corresponding to ``dow`` with ``1 = Monday, 2 = Tuesday, etc``. Setting ``same=true`` allows the current ``dt`` to be considered as the previous ``dow``, allowing for no adjustment to occur. @@ -314,7 +314,7 @@ Adjuster Functions .. function:: recur{T<:TimeType}(func::Function,dr::StepRange{T};negate=false,limit=10000) -> Vector{T} ``func`` takes a single TimeType argument and returns a ``Bool`` indicating whether the input - should be "included" in the final set. ``recur`` applies ``func`` over each element in the + should be "included" in the final set. ``recur`` applies ``func`` over each element in the range of ``dr``, including those elements for which ``func`` returns ``true`` in the resulting Array, unless ``negate=true``, then only elements where ``func`` returns ``false`` are included. diff --git a/doc/stdlib/linalg.rst b/doc/stdlib/linalg.rst index de126a67294f3..ab43c676bf419 100644 --- a/doc/stdlib/linalg.rst +++ b/doc/stdlib/linalg.rst @@ -173,7 +173,7 @@ Linear algebra functions in Julia are largely implemented by calling functions f Converts an orthogonal or unitary matrix stored as a ``QRCompactWYQ`` object, i.e. in the compact WY format [Bischof1987]_, to a dense matrix. - + Optionally takes a ``thin`` Boolean argument, which if ``true`` omits the columns that span the rows of ``R`` in the QR factorization that are zero. The resulting matrix is the ``Q`` in a thin QR factorization (sometimes diff --git a/doc/stdlib/pkg.rst b/doc/stdlib/pkg.rst index 820e6001e7f28..9787a90619b2b 100644 --- a/doc/stdlib/pkg.rst +++ b/doc/stdlib/pkg.rst @@ -21,7 +21,7 @@ to use them, you'll need to prefix each function call with an explicit ``Pkg.``, .. function:: init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH) - Initialize ``Pkg.dir()`` as a package directory. + Initialize ``Pkg.dir()`` as a package directory. This will be done automatically when the ``JULIA_PKGDIR`` is not set and ``Pkg.dir()`` uses its default value. As part of this process, clones a local METADATA git repository from the site and branch specified by its arguments, which are typically not provided. Explicit (non-default) arguments can be used to support a custom METADATA setup. diff --git a/doc/stdlib/test.rst b/doc/stdlib/test.rst index 7695273c66c79..6f0d91f154581 100644 --- a/doc/stdlib/test.rst +++ b/doc/stdlib/test.rst @@ -30,7 +30,7 @@ provided by the user by using the :func:`registerhandler` function. To use the default handler, the macro :func:`@test` can be used directly:: julia> using Base.Test - + julia> @test 1 == 1 julia> @test 1 == 0 diff --git a/src/Makefile b/src/Makefile index 58caeb708fd54..bb1b96b30b133 100644 --- a/src/Makefile +++ b/src/Makefile @@ -72,7 +72,7 @@ $(julia_flisp.boot): julia-parser.scm julia-syntax.scm \ @$(call PRINT_FLISP, $(call spawn,$(BUILDDIR)/flisp/flisp) ./mk_julia_flisp_boot.scm) $(BUILDDIR)/ast.o $(BUILDDIR)/ast.dbg.obj: $(BUILDDIR)/julia_flisp.boot.inc flisp/*.h -$(BUILDDIR)/codegen.o $(BUILDDIR)/codegen.dbg.obj: intrinsics.cpp cgutils.cpp ccall.cpp +$(BUILDDIR)/codegen.o $(BUILDDIR)/codegen.dbg.obj: intrinsics.cpp cgutils.cpp ccall.cpp $(BUILDDIR)/builtins.o $(BUILDDIR)/builtins.dbg.obj: table.c $(BUILDDIR)/support/libsupport.a: support/*.h support/*.c