MyGit

v1.17.0-rc.0

elixir-lang/elixir

版本发布时间: 2024-05-24 20:31:53

elixir-lang/elixir最新发布版本:v1.17.0-rc.0(2024-05-24 20:31:53)

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

Warnings from gradual set-theoretic types

This release introduces gradual set-theoretic types to infer types from patterns and guards 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 that not all maps have statically known keys, and the Elixir typechecker only infers types from patterns at the moment.

Future Elixir versions will infer and type check more constructs, bringing Elixir developers more warnings and quality of life improvements without changes to code. 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))

1. Enhancements

Elixir

ExUnit

IEx

Logger

Mix

2. Bug fixes

Elixir

IEx

Mix

3. Soft deprecations (no warnings emitted)

Elixir

4. Hard deprecations

Elixir

ExUnit

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

1、 Docs.zip 5.99MB

2、 Docs.zip.sha1sum 51B

3、 Docs.zip.sha256sum 75B

4、 elixir-otp-25.exe 7.09MB

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

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

7、 elixir-otp-25.zip 7.05MB

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

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

10、 elixir-otp-26.exe 7.01MB

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

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

13、 elixir-otp-26.zip 6.98MB

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

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

16、 elixir-otp-27.exe 7.01MB

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

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

19、 elixir-otp-27.zip 6.98MB

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

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

查看:2024-05-24发行的版本