This commit introduces an optional callback `inspect/2`
that allows custom calendars to define a implementation
for the `Inspect` protocol for `Time`, `Date`,
`DateTime`, and `NaiveDateTime`.
Otherwise we may have a race condition if the code
is passing __ENV__ to an eval function which may keep
the lexical tracker if it is alive by the time it is
checked.
Prior to this patch, we would always compute the relative
path to the current working directory (CWD), but this meant
consolidated protocols would always get a full path since
they are always outside of their current working directory.
We address this by also storing the relative path in the
definition.
Closes#9095
Before we hadn't added guards to functions in the Stream module
because the error message for invoking a function with the wrong
number of arguments was better than the FunctionClauseError. Now
that FunctionClauseErrors are better and display the failed
clauses and everything, having guards in Stream functions means
that we can fail fast in many cases instead of waiting to fail
until the stream is realized.
Regexes used to be precompiled to binary values during code
compilation. These binary values may be incompatible with
different operating systems and OTP releases. That's why
an explicit `Regex.recompile/1` or `Regex.recompile!/1` was
required.
Regexes now fallback to binary matching if the precompiled
binary is not compatible with the runtime version.
Regexes are precompiled to binary values during code compilation.
These binary values may be incompatible between different PCRE versions
and OS endianness. This makes code less portable to achieve slight
performance improvement.
PCRE version and endianness are parts of Regex structure and may be
checked in runtime.
This commit adds this check and makes regex execution fall back
to binary matching if versions are incompatible.
This slightly reduces performance (around 5% for simple regexes) for
compatible versions because there is an additional version read.
Also for incompatible versions it's as fast as binary matching.