Age | Commit message (Collapse) | Author |
|
Update global name typespec
|
|
Introduce is_map_key/2 guard BIF
OTP-15037
|
|
This complements the `map_get/2` guard BIF introduced in #1784.
Rationale.
`map_get/2` allows accessing map fields in guards, but it might be
problematic in more complex guard expressions, for example:
foo(X) when map_get(a, X) =:= 1 or is_list(X) -> ...
The `is_list/1` part of the guard could never succeed since the
`map_get/2` guard would fail the whole guard expression. In this
situation, this could be solved by using `;` instead of `or` to separate
the guards, but it is not possible in every case.
To solve this situation, this PR proposes a `is_map_key/2` guard that
allows to check if a map has key inside a guard before trying to access
that key. When combined with `is_map/1` this allows to construct a
purely boolean guard expression testing a value of a key in a map.
Implementation.
Given the use case motivating the introduction of this function, the PR
contains compiler optimisations that produce optimial code for the
following guard expression:
foo(X) when is_map(X) and is_map_key(a, X) and map_get(a, X) =:= 1 -> ok;
foo(_) -> error.
Given all three tests share the failure label, the `is_map_key/2` and
`is_map/2` tests are optimised away.
As with `map_get/2` the `is_map_key/2` BIF is allowed in match specs.
|
|
|
|
* siri/kernel/logger/OTP-13295:
Add documentation of the built-in logger handlers
Catch badarg in logger:get_format_depth/0
Add chars_limit option to logger_formatter
Don't kill logger process until all other processes are dead
Set call timeout for logger_server to infinity
Update primary bootstrap
Test cuddle for logger
Update cth_log_redirect to a logger handler
Start using logger internally in kernel and stdlib
Remove error_logger process and add logger process
Add logger
|
|
* hasse/stdlib/rfc3339_datetime/OTP-14764:
stdlib: Add RFC 3339 functions to module calendar
|
|
|
|
Allow installing multiple instances of sys debug function
This commit solves a bug which allowed installing {Fun,State} as sys debug function even if Fun was already installed. This happened in the case when the current State of the debug fun was undefined.
Also, the new format {Id,Fun,State} of debug functions can be installed, allowing multiple instances of the same fun.
|
|
[stdlib/sys.erl] Fix sys module's debug statistics not including the out message count when using gen_server:call/2.
OTP-15047
|
|
Functions for converting between RFC 3339 strings and system time
are added.
Options are lists, but we are considering using maps instead. If we
change, it will happen after Erlang/OTP 21.0-rc1 is released.
|
|
* hasse/stdlib/calendar_systemtime/OTP-13413:
stdlib: Add system time functions to module calendar
|
|
|
|
Use the same depth for all (printed) elements of a map.
Since the order of keys can vary when printing a map--maps:iterator/1
and maps:next/1 are used--it is more consistent to print all
associations with the same depth.
If the associations printed are limited by the depth, the selection
of associations is arbitrary, as before.
|
|
Inspiration from module lager_format.
Also some improvements of Unicode handling.
io_lib:format/3 and io_lib:fwrite/3 are new functions. The
representation of the options is a list, but we are considering using
a map instead. If we change, it will happen after Erlang/OTP 21.0-rc1
is released.
|
|
A bug fix: limited maps end with "...", not "...=>...".
A modification: wW separate pairs with " => ", not "=>".
When the output is limited on number of characters, the term is
balanced by wW the same way as is done with pP (see commit bc38638).
|
|
|
|
The name of the io_lib_pretty:print/2 option 'max_chars' is changed to
'line_max_chars' (used by module shell only).
The new option for limiting the number of returned characters of
io_lib_pretty:print() is called 'chars_limit'.
|
|
* hasse/stdlib/map_guards_shell/OTP-15035/ERL-613:
erts: Correct abstract format doc regarding map creation
stdlib: Correct the linter's check of map guard expressions
|
|
* 'map-get-bif' of git://github.com/michalmuskala/otp:
Introduce map_get guard-safe function
OTP-15037
|
|
The check is used by evaluating modules such as erl_eval.
An example: "if map_size(#{}) =:= 0 -> ok end.".
|
|
* raimo/stdlib/gen_statem-dev/OTP-14015:
Fix after feedback
Improve pointer to User's Guide
Fix after feedback on 'When to use'
Add a 'When to use' section
Fix timeout parsing and doc feedback
Improve doc, change images to .svg
erl_docgen: Implement width in image tag
Update User's Guide and pointers to it
Improve error reasons from state enter call
|
|
Rationale
Today all compound data types except for maps can be deconstructed in guards.
For tuples we have `element/2` and for lists `hd/1` and `tl/1`. Maps are
completely opaque to guards. This means matching on maps can't be
abstracted into macros, which is often done with repetitive guards. It
also means that maps have to be always selected whole from ETS tables,
even when only one field would be enough, which creates a potential
efficiency issue.
This PR introduces an `erlang:map_get/2` guard-safe function that allows
extracting a map field in guard. An alternative to this function would be
to introduce the syntax for extracting a value from a map that was planned
in the original EEP: `Map#{Key}`.
Even outside of guards, since this function is a guard-BIF it is more
efficient than using `maps:get/2` (since it does not need to set up the
stack), and more convenient from pattern matching on the map (compare:
`#{key := Value} = Map, Value` to `map_get(key, Map)`).
Performance considerations
A common concern against adding this function is the notion that "guards
have to be fast" and ideally execute in constant time. While there are
some counterexamples (`length/1`), what is more important is the fact
that adding those functions does not change in any way the time
complexity of pattern matching - it's already possible to match on map
fields today directly in patterns - adding this ability to guards will
niether slow down or speed up the execution, it will only make certain
programs more convenient to write.
This first version is very naive and does not perform any optimizations.
|
|
Currently, in sys:stat/2, the message out only count for system events with format
{out, Msg, To}. However, the gen_server:reply/5 will call sys:handle_debug/4
with format {out, Reply, To, State}. That will make the message out count fail
to pattern matching.
Also update sys_SUITE.erl and relevant docs.
|
|
|
|
Those warnings don't make sense any more since erlang:get_stacktrace/0
is now deprecated.
|
|
|
|
|
|
Compile external fun expressions to literals
OTP-15003
|
|
* dgud/revert-string-depr:
Revert "Deprecate old string functions"
|
|
The expressions fun M:F/A, when all elements are literals are also
treated as a literal. Since they have consistent representation and
don't depend on the code currently loaded in the VM, this is safe.
This can provide significant performance improvements in code using such
functions extensively - a full function call to erlang:make_fun/3 is
replaced by a single move instruction and no register shuffling or
saving registers to stack is necessary. Additionally, compound data
types that contain such external functions as elements can be treated as
literals too.
The commit also changes the representation of external funs to be a
valid Erlang syntax and adds support for literal external funs to core
Erlang.
|
|
* raimo/type-posix-0-overhaul/ERL_550/OTP-14019:
Update types for posix error codes
|
|
I have read the man pages for most socket and file operations
on recent Linux, FreeBSD, OpenBSD and Solaris 10 and noted
the possible error codes.
Which error codes that are possible for file operations have
been updated in file:posix/0. Error codes for socket operations
in inet:posix/0. The latter refers to the former so it is
a superset, assuming that e.g sendfile and AF_UNIX socket
operations could cause socket operations to return any file
error code. That is not entirely true, but could be,
especially in the future.
Added to file:posix/0 are:
ebadmsg edeadlk edeadlock eftype emultihop enobufs enolck enolink
enosr enostr enosys eopnotsupp eoverflow erange etxtbsy
Added to inet:posix/0 are all but:
exbadport exbadseq file:posix()
These are still possible according to erl_posix_str.c,
but are not in file:posix/0 nor in inet:posix/0,
and many of them are not file nor inet related, but some might be:
e2big eadv ealign ebade ebadfd ebadr ebadrpc ebadrqc
ebadslt ebfont echild echrng ecomm edirty
edom edotdot eduppkg eidrm einit eisnam
elbin el2hlt el2nsync el3hlt el3rst
elibacc elibbad elibexec elibmax elibscn elnrng
enavail enet enoano enocsi enodata enoexec
enonet enosym enotempty enotnam enotuniq
eproclim eprocunavail eprogmismatch eprogunavail
erefused eremchg eremdev eremote eremoteio
eremoterelease erpcmismatch erremote eshutdown
esrmnt esuccesss etime etoomanyrefs
euclean eunatch eusers eversion exfull
sysnotready vernotsupported ediscon enomore
ecancelled einvalidproctable einvalidprovider eproviderfailedinit
syscallfailure service_not_found type_not_found e_no_more
e_cancelled unknown
|
|
[ERL-557] add is_empty/1 to sets and ordsets
OTP-14996, ERL-557, PR-1703
|
|
It has been decided that it was to early to deprecate the old
string functions.
This partially reverts commit ccb3f7f9768d3c28783c771df47eec1829e51802.
|
|
|
|
* maint:
Updated OTP version
Update release notes
Update version numbers
ssh: Fix bad spec for double_algs() in ssh.hrl
Test event insert from init
Fix init to allow all actions
Conflicts:
OTP_VERSION
|
|
stdlib: Add function lists:search/2
|
|
|
|
|
|
make erlang:process_info/1 not retrieve messages
|
|
|
|
|
|
Allow multiple modifier characters in io:format control sequences
OTP-14971
|
|
This makes it possible to print unicode atoms at the same time as
suppressing detection of printable lists.
|
|
process_info/1 retrieves a number of properties related to a process,
including the list of messages in its mailbox. This is potentially
unsafe if the target process has a large number of queued messages:
- there is no a priori upper bound on the amount of memory being
allocated to hold that list, and
- the loop to retrieve the messages is uninterruptible, so the
Erlang scheduler where this executes blocks for the duration
We've seen process_info/1 bring down heavily loaded nodes on more
than one occasion. At least once it appeared to have blocked the
Erlang heart process from executing, causing the external heart to
kill the VM.
Consequently this removes 'messages' from the list of process_info
tags to retrieve for process_info/1. Note that process_info/1 still
retrieves 'message_queue_len', and process_info/2 can still retrieve
'messages' when asked to.
A few places in the OTP libraries need minor adjustments, since they
want 'message_queue_len' but compute it from the length of the list
of messages.
|
|
This is essentially PR 102, https://github.com/erlang/otp/pull/102.
The OTP Technical Board decided to change the name of the function to
search/2.
|
|
Make io_lib:unscan_format/1 work with pad char and default precision
OTP-14958
|
|
Improve handling of maps. Addendum to b57e890.
|
|
Optimization does not trigger for try-catch.
But send cannot fail here anyway, as Process cannot be an atom.
|
|
as workarounds to avoid blocking auto-connect,
which is now asynchronous in OTP-21.
Also changed old catch to more efficient try-catch.
|