MyGit

v1.17.0

elixir-lang/elixir

版本发布时间: 2024-06-12 18:37:42

elixir-lang/elixir最新发布版本:v1.17.2(2024-07-07 05:20:46)

https://elixir-lang.org/blog/2024/06/12/elixir-v1-17-0-released/

This release includes type inference of patterns to provide warnings for an initial set of constructs (binaries, maps, and atoms) within the same function. It also includes a new Duration data type to interact with Calendar types, support for Erlang/OTP 27, and many other improvements.

Warnings from gradual set-theoretic types

This release introduces gradual set-theoretic types to infer types from patterns and use them to type check programs, enabling the Elixir compiler to find faults and bugs in codebases without requiring changes to existing software. The underlying principles, theory, and roadmap of our work have been outlined in "The Design Principles of the Elixir Type System" by Giuseppe Castagna, Guillaume Duboc, José Valim.

At the moment, Elixir developers will interact with set-theoretic types only through warnings found by the type system. The current implementation models all data types in the language:

We focused on atoms and maps on this initial release as they are respectively the simplest and the most complex types representations, so we can stress the performance of the type system and quality of error messages. Modelling these types will also provide the most immediate benefits to Elixir developers. Assuming there is a variable named user, holding a %User{} struct with an address field, Elixir v1.17 will emit the following warnings at compile-time:

These new warnings help Elixir developers find bugs earlier and give more confidence when refactoring code, especially around maps and structs. While some of these warnings were emitted in the past, they were discovered using syntax analysis. The new warnings are more reliable, precise, and with better error messages. Keep in mind, however, that the Elixir typechecker only infers types from patterns within the same function at the moment. Analysis from guards and across function boundaries will be added in future relases. For more details, see our new reference document on gradual set-theoretic types.

The type system was made possible thanks to a partnership between CNRS and Remote. The development work is currently sponsored by Fresha, Starfish*, and Dashbit.

Erlang/OTP support

This release adds support for Erlang/OTP 27 and drops support for Erlang/OTP 24. We recommend Elixir developers to migrate to Erlang/OTP 26 or later, especially on Windows. Support for WERL (a graphical user interface for the Erlang terminal on Windows) will be removed in Elixir v1.18.

Adding Duration and shift/2 functions

Elixir introduces the Duration data type and APIs to shift dates, times, and date times by a given duration, considering different calendars and time zones.

iex> Date.shift(~D[2016-01-31], month: 2)
~D[2016-03-31]

Note the operation is called shift (instead of add) since working with durations does not obey properties such as associativity. For instance, adding one month and then one month does not give the same result as adding two months:

iex> ~D[2016-01-31] |> Date.shift(month: 1) |> Date.shift(month: 1)
~D[2016-03-29]

Still, durations are essential for building intervals, recurring events, and modelling scheduling complexities found in the world around us. For DateTimes, Elixir will correctly deal with time zone changes (such as Daylight Saving Time), but provisions are also available in case you want to surface conflicts (for example, you shifted to a wall clock that does not exist, because the clock has been moved forward by one hour). See DateTime.shift/2 for examples.

Finally, a new Kernel.to_timeout/1 function has been added, which helps developers normalize durations and integers to a timeout used by Process APIs. For example, to send a message after one hour, one can now write:

Process.send_after(pid, :wake_up, to_timeout(hour: 1))

v1.17.0 (2024-06-12)

1. Enhancements

Elixir

ExUnit

IEx

Logger

Mix

2. Bug fixes

Elixir

IEx

Mix

3. Soft deprecations (no warnings emitted)

Elixir

Mix

4. Hard deprecations

Elixir

ExUnit

相关地址:原始地址 下载(tar) 下载(zip)

1、 Docs.zip 6.01MB

2、 Docs.zip.sha1sum 51B

3、 Docs.zip.sha256sum 75B

4、 elixir-otp-25.exe 7.13MB

5、 elixir-otp-25.exe.sha1sum 60B

6、 elixir-otp-25.exe.sha256sum 84B

7、 elixir-otp-25.zip 7.1MB

8、 elixir-otp-25.zip.sha1sum 60B

9、 elixir-otp-25.zip.sha256sum 84B

10、 elixir-otp-26.exe 7.05MB

11、 elixir-otp-26.exe.sha1sum 60B

12、 elixir-otp-26.exe.sha256sum 84B

13、 elixir-otp-26.zip 7.02MB

14、 elixir-otp-26.zip.sha1sum 60B

15、 elixir-otp-26.zip.sha256sum 84B

16、 elixir-otp-27.exe 7.05MB

17、 elixir-otp-27.exe.sha1sum 60B

18、 elixir-otp-27.exe.sha256sum 84B

19、 elixir-otp-27.zip 7.02MB

20、 elixir-otp-27.zip.sha1sum 60B

21、 elixir-otp-27.zip.sha256sum 84B

查看:2024-06-12发行的版本