Elixir v1.3.0-rc.1 发布,函数式编程语言

jopen 6年前
   <p style="text-align: center;"><img alt="" src="https://simg.open-open.com/show/33a2f4f61d4afed250b256b618ed4e69.jpg" /></p>    <p> </p>    <p>Elixir 是一种函数式编程语言,建立在Erlang虚拟机之上。它是一种动态语言,灵活的语法与宏支持,利用Erlang的能力来构建并发、分布式、容错应用程序与热代码升级。</p>    <h2>更新日志</h2>    <h3>1. 功能增强</h3>    <p>EEx</p>    <ul>     <li>[EEx.Engine] Support an <code>init/1</code> function in engines that will return the initial buffer (defaults to an empty string)</li>    </ul>    <p>Elixir</p>    <ul>     <li>[Access] Add support for <code>Access.all/0</code>, <code>Access.elem/1</code>, <code>Access.key/2</code> and <code>Access.key!/1</code> for traversing nested data structures</li>     <li>[Calendar] Add <code>Calendar</code> and <code>Date</code>, <code>Time</code>, <code>NaiveDateTime</code> and <code>DateTime</code> types</li>     <li>[CLI] Add <code>--logger-otp-reports BOOL</code> and <code>--logger-sasl-reports BOOL</code> switches</li>     <li>[Compiler] Emit a summary of compilation errors when modules are missing</li>     <li>[Enum] Add <code>Enum.group_by/3</code> that allows developers to map on the value being grouped</li>     <li>[Enum] Add <code>Enum.drop_every/2</code> that drops every <code>nth</code>, including the first one</li>     <li>[Exception] Suggest possible functions on <code>UndefinedFunctionError</code> for existing modules</li>     <li>[Exception] Warn if unknown fields are given to <code>raise/2</code></li>     <li>[File] Support IO devices in <code>File.copy/3</code></li>     <li>[GenServer] Raise a more meaningful exit if you try to <code>GenServer.call/3</code> yourself</li>     <li>[Inspect] Support <code>:base</code> option when inspecting binaries</li>     <li>[IO] Add <code>IO.warn/2</code> that will print a warning message with stacktrace and notify the compiler a warning was printed (in case --warnings-as-errors was enabled)</li>     <li>[Kernel] Support <code>generated: true</code> in quote</li>     <li>[Kernel] Support <code>Kernel.pop_in/1</code> and <code>Kernel.pop_in/2</code> for yanking a value from a nested data structure</li>     <li>[Kernel] Allow variable struct names when matching, for example, <code>%module{key: "value"} = struct</code></li>     <li>[Kernel] Allow guards on the left side of <code><-</code> in <code>for</code> and <code>with</code> special forms</li>     <li>[Kernel] Support <code>else</code> chunks in <code>with</code></li>     <li>[Kernel] Track <code>{module, function, arity}</code> imports and warn on unused ones when such are specified in <code>:only</code></li>     <li>[Kernel] Add <code>keyword/0</code> and <code>keyword/1</code> built-in types to typespecs</li>     <li>[Kernel] Add sigils for date (<code>~D[2015-04-17]</code>), time (<code>~T[08:00:00]</code>) and naive date times <code>~N[2015-04-17 08:00:00]</code></li>     <li>[Kernel] Support <code>@enforce_keys</code> on <code>defstruct/1</code> to guarantee some keys are explicitly given when building structs</li>     <li>[OptionParser] Add support for <code>:count</code> switch type</li>     <li>[OptionParser] Add <code>parse!/2</code> and <code>parse_head!/2</code> that raise <code>OptionParser.ParseError</code> in case of errors</li>     <li>[Process] Add <code>Process.sleep/1</code></li>     <li>[Range] <code>Range.range?/1</code> now checks the validity of a range.</li>     <li>[Regex] Support <code>:include_captures</code> in <code>Regex.split/3</code></li>     <li>[String] Add <code>String.myers_difference/2</code> for calculating the difference between two strings</li>     <li>[System] Add <code>System.os_time/0</code> and <code>System.os_time/1</code></li>     <li>[Typespec] Add support for <code>%{required(foo) => bar}</code> and <code>%{optional(foo) => bar}</code> forms (Erlang 19 only)</li>     <li>[Typespec] Add support for <code>@optional_callbacks</code> to mark certain that certain callbacks may be optionally implemented</li>     <li>[Typespec] Introduce <code>%{...}</code> to mean any map (Erlang 19 only)</li>     <li>[URI] Add <code>URI.merge/2</code></li>     <li>[Version] Add <code>Version.parse!/1</code></li>    </ul>    <p>ExUnit</p>    <ul>     <li>[ExUnit] Show pinned variables on failed <code>assert ^left = right</code> and <code>assert match?(^left, right)</code>assertions</li>     <li>[ExUnit] Add <code>ExUnit.Case.register_attribute</code> which allow attributes to be cleaned up whenever a test is defined</li>     <li>[ExUnit] Add <code>ExUnit.Case.register_test</code> and support the ability to tag "tests" by type. This will allow projects like QuickCheck to change the wording in formatters to say "10 properties" instead of "10 tests"</li>     <li>[ExUnit] Support diffing of values when using <code>==</code> in <code>assert</code></li>     <li>[ExUnit] Start running tests as soon as cases are loaded. This feature is enabled by default when running tests through Mix</li>     <li>[ExUnit] Raise a straight-forward error message in case a duplicate test name is defined</li>     <li>[ExUnit] Bump the default number of max cases to double of schedulers to support both IO and CPU bound tests</li>     <li>[ExUnit] Support for named setups in <code>setup</code> and <code>setup_all</code></li>     <li>[ExUnit] Support for bundling tests together with <code>describe/2</code></li>    </ul>    <p>IEx</p>    <ul>     <li>[IEx] Add <code>nl/2</code> that loads a given modules on a list of nodes</li>     <li>[IEx.Helpers] No longer restart applications on <code>recompile/1</code></li>     <li>[IEx.Autocomplete] Improve IEx expand to handle functions after <code>&</code></li>    </ul>    <p>Logger</p>    <ul>     <li>[Logger] Introduce <code>Logger.reset_metadata/0,1</code></li>    </ul>    <p>Mix</p>    <ul>     <li>[Mix] Add <code>mix xref</code> and <code>mix compile.xref</code> that runs cross-reference checks, with the latter running after compilation by default</li>     <li>[Mix] Add <code>mix app.tree</code> and <code>mix deps.tree</code></li>     <li>[Mix] Add <code>Mix.Task.rerun/2</code> that reenables and re-runs a task</li>     <li>[Mix] Integrate <code>OptionParser.ParseError</code> into Mix, automatically converting such exceptions into<code>Mix.Error</code> and embedding the task information</li>     <li>[Mix] Support <code>@preferred_cli_env</code> attribute when defining tasks</li>     <li>[Mix] Support <code>mix test --raise</code> that will raise when a test suite fails (instead of setting the exit code to 1)</li>     <li>[Mix] Enable rebar3 manager by default for Hex dependencies</li>     <li>[Mix] Add <code>mix escript.install</code> to install escripts</li>     <li>[Mix] Print stacktraces for <code>Mix.Error</code> when <code>MIX_DEBUG=1</code> is set</li>     <li>[Mix] Add a user friendly error for merge conflicts on <code>mix.lock</code></li>     <li>[Mix] Track files between path dependencies. This means umbrella applications will no longer trigger full recompilation when a sibling changes. Instead it will only recompile the files affected by the sibling changes</li>     <li>[Mix] No longer print every file being compiled. Instead a generic "Compiling N files (.ext)" will be printed and files will only be logged in case they take more than 5 seconds to compile. This threshold can be customized by passing the <code>--long-compilation-threshold</code> flag and the previous behaviour can be reenabled by giving <code>--verbose</code> to <code>mix compile</code></li>     <li>[Mix] Add <code>mix test --stale</code> that uses static analysis on source files to know which tests should run when source files changes. If any test file changes, it will also re-run. Changing a configuration file or the test helper will trigger a full recompilation</li>    </ul>    <h3>2. Bug修复</h3>    <p>Elixir</p>    <ul>     <li>[Application] Ensure <code>Application.spec/2</code> returns nil for unknown applications</li>     <li>[GenServer] Ensures <code>cast/2</code> returns <code>:ok</code> if locally registered process is not found</li>     <li>[Inspect] Ensure binaries break into new lines when inspected</li>     <li>[Kernel] Do not choke on capture operator with argument above <code>&191</code></li>     <li>[Kernel] Raise if <code>defstruct</code> is called multiple times</li>     <li>[Kernel] Ensure <code>Module.create/3</code> respects var/alias hygiene</li>     <li>[Kernel] Support non-literal ranges on the right side of <code>in/2</code></li>     <li>[Macro] Fix <code>Macro.to_string/1</code> on a call of a capture argument, for example <code>&(&1).(:x)</code></li>     <li>[OptionParser] Allow <code>OptionParser</code> to parse negative numbers</li>     <li>[Record] Fix <code>Record.is_record/2</code> when dealing with non-record tuples</li>     <li>[String] Ensure <code>strip</code> also removes non-breaking whitespaces (and ensure <code>split</code> still does not split on them)</li>     <li>[URI] Use square brackets for IPv6 in <code>URI.to_string/1</code></li>    </ul>    <p>Mix</p>    <ul>     <li>[Mix] Improve task not found message when Mix would include the not found task as a suggestion due to different casing</li>     <li>[Mix] Ignore lock revision when the lock is out of date when updating Mix dependencies. Before this fix, git tags and branches in the lock file would erroneously take higher precedence than the one in<code>mix.exs</code></li>     <li>[Mix] Only recompile empty Elixir files if they change instead of recompiling them on every run</li>     <li>[Mix] Ensure .app file is written in UTF-8 (this allows app descriptions to contain UTF-8 characters)</li>     <li>[Mix.Dep] Always specify the <code>:env</code> option internally for dependencies to avoid false positives in the dependency resolution</li>     <li>[Mix.Dep] Correctly detect conflict from cousin optional dependencies in the dependency resolution algorithm</li>    </ul>    <h3>3.软弃用(no warnings emitted)</h3>    <ul>     <li>[Float] <code>Float.to_string/2</code> and <code>Float.to_char_list/2</code> has been soft-deprecated as Elixir will now attempt to print the shortest and most accurate representation by default. Developers can always fallback to <code>:erlang.float_to_binary/2</code> and <code>:erlang.float_to_list/2</code> if they need the previous functionality</li>     <li>[Kernel] <code>to_char_list</code> functions have been soft-deprecated in favor of <code>to_charlist</code>. This aligns with the naming conventions in both Erlang and Elixir</li>     <li>[String] The confusing <code>String.strip/2</code>, <code>String.lstrip/2</code> and <code>String.rstrip/2</code> API has been soft deprecated in favor of <code>String.trim/2</code>, <code>String.trim_leading/2</code> and <code>String.trim_trailing/2</code></li>     <li>[String] The confusing <code>String.ljust/3</code> and <code>String.rjust/3</code> API has been soft deprecated in favor of <code>String.pad_leading/3</code> and <code>String.pad_trailing/3</code></li>     <li>[Typespec] <code>char_list</code> is soft-deprecated in favor of <code>charlist</code></li>    </ul>    <h3>4. 弃用</h3>    <p>This release deprecates many APIs that have been soft-deprecated in previous Elixir versions.</p>    <p>Elixir</p>    <ul>     <li>[Dict] <code>Dict</code> is no longer a behaviour and its functions will be deprecated in upcoming releases</li>     <li>[Enum] Passing a dictionary to <code>Enum.group_by/3</code> is deprecated</li>     <li>[Kernel] <code>\x{H*}</code> in strings/sigils/charlists is deprecated</li>     <li>[Kernel] Add deprecation for <code>defdelegate</code> list arguments and <code>:append_first</code> option</li>     <li>[Kernel] Warn if a variable is assigned inside <code>case</code>/<code>if</code>/etc and used outside the block</li>     <li>[Keyword] <code>Keyword.size/1</code> is deprecated in favor of <code>Kernel.length/1</code></li>     <li>[Map] <code>Map.size/1</code> is deprecated in favor of <code>Kernel.map_size/1</code></li>     <li>[Regex] The option <code>/r</code> (for ungreedy) has been deprecated in favor of <code>/U</code></li>     <li>[Set] <code>Set</code> is no longer a behaviour and its functions will be deprecated in upcoming releases</li>     <li>[String] <code>String.valid_character?/1</code> is deprecated in favor of <code>String.valid?/1</code> with pattern matching</li>     <li>[Task] <code>Task.find/2</code> is deprecated in favor of explicit message matching</li>     <li>[URI] Passing a non-map to <code>URI.decode_query/3</code> is deprecated</li>    </ul>    <h2>下载</h2>    <ul>     <li><a href="/misc/goto?guid=4958991260850868565" rel="nofollow">1.09 MB<strong>Docs.zip</strong></a></li>     <li><a href="/misc/goto?guid=4958991260956811454" rel="nofollow">3.41 MB<strong>Precompiled.zip</strong></a></li>     <li><a href="/misc/goto?guid=4958991261049087380" rel="nofollow"><strong>Source code</strong> (zip)</a></li>     <li><a href="/misc/goto?guid=4958991261150462892" rel="nofollow"><strong>Source code</strong> (tar.gz)</a></li>    </ul>