-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsspeculativeWhether the change will be implemented is speculativeWhether the change will be implemented is speculative
Description
Given the importance of type stability, I would like to propose a new language construct that would allow semi-static checking of type stable blocks. In the module I am developing, I am frequently using this type of construct
function f(a)
# Type stability
@stabilize m::Matrix{Float64} = a.m
# Compute things with m
end
...I know there are:
- The possibility to use a function - but this can be cumbersome when there are many types, and in makes the code harder to read (at least for me)
- Tools like Lint or TypeCheck, and the macro
@code_warntypethat are useful to see/check whether the written code is type stable
but I would really like to have something that prevents code from being instable, e.g. using a "stable block" (I check and this gives a syntax error with julia 0.[34]):
function f(a)
# Type stability
@stabilize m::Matrix{Float64} = a.m
stable begin
# Compute things - compilation error (or warning) if there is some type instability within the code
end
end
...Another syntactic possibility would be to use pragmas #7449 (if they make it in the language).
GiggleLiu, cstjean, carstenbauer, rapus95, kcajf and 5 more
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsspeculativeWhether the change will be implemented is speculativeWhether the change will be implemented is speculative