-
Notifications
You must be signed in to change notification settings - Fork 1
2022 02 08 report
Last week I added two things to the current project:
- An eager version of the
@stable
macro to check a function definition for stability. - An utility called
is_stable_module
that hopefully makes it easier to check more code using our approach.
Here are some details on both.
On last week Julia meeting, Yulia pointed out that my@stable
macro is
too eager: it will fail for a function calling another, not-yet-defined
function. E.g.:
@stable f() = g() @stable g() = 1
Including a file with such content will flag f
as unstable because it
calls unknown (at that point) function g
that, therefore, can return
Any
.
The workaround is straightforward: put the given definition into a
worklist to be processed later. The exact moment is decided by the user:
they have to call check_all_stable()
then. That’s is less nice, of
course, but I can’t think of a better solution.
Right now, @stable
works for the above example as expected (both
functions are stable). The old, eager strategy is still around by the
name @stable!
(note the bang) in case the user knows that checking
right now is okay.
Here’s an example with first three functions in a module stable and the last one not.
module M export a, b, c; a()=1; b()=2; c=3; d()=if rand()>0.5; 1; else ""; end end
By default the utility checks only exported names, so only the first three functions will be checked by default. The following tests will pass:
@testset "is_stable_module" begin @test is_stable_module(M) @test ! is_stable_module(M, SearchCfg(exported_names_only=false)) end
For next week I was going to improve reporting of unstable module members and then try on real modules.