Releases: MilesCranmer/BorrowChecker.jl
v0.2.1
BorrowChecker v0.2.1
Merged pull requests:
- fix LazyAccessor recursive
setproperty!(setindex!(...))(#30) (@MilesCranmer)
v0.2.0
BorrowChecker v0.2.0
Breaking Changes
The @bc macro now defaults to creating immutable references, even if you have a mutable reference as an input variable (#29). For example:
julia> @own :mut x = [1, 2, 3]
OwnedMut{Vector{Int64}}([1, 2, 3], :x)
julia> @lifetime lt begin
@ref ~lt :mut r = x
@bc typeof(r)
end
Borrowed{Vector{Int64}, OwnedMut{Vector{Int64}}}whereas before, this would be a BorrowedMut. We can get this behavior again by explicitly marking it as @mut.
julia> @lifetime lt begin
@ref ~lt :mut r = x
@bc typeof(@mut(r))
end
BorrowedMut{Vector{Int64}, OwnedMut{Vector{Int64}}}Other changes
- feat: allow immutable borrow of mutable borrow by @MilesCranmer in #27
- fix: forwarding of
randnby @MilesCranmer in #28
Merged pull requests:
- feat: allow immutable borrow of mutable borrow (#27) (@MilesCranmer)
- fix: forwarding of
randn(#28) (@MilesCranmer) - BREAKING CHANGE: make
@bcdefault to immutable (#29) (@MilesCranmer)
v0.1.5
BorrowChecker v0.1.5
Merged pull requests:
- fix:
@&when wrapping type parameters (#26) (@MilesCranmer)
v0.1.4
BorrowChecker v0.1.4
Merged pull requests:
- refactor: unify abstract types (#19) (@MilesCranmer)
- Create Mutex (#21) (@MilesCranmer)
- feat: add basic broadcasting compatibility (#22) (@MilesCranmer)
- Fix a few type instabilities (#24) (@MilesCranmer)
- feat: create
@¯o for borrowed types (#25) (@MilesCranmer)
Closed issues:
- Mutex feature (#16)
v0.1.3
BorrowChecker v0.1.3
Merged pull requests:
- feat: overload
reshape(#13) (@MilesCranmer) - Create
@cc, a closure check macro (#14) (@MilesCranmer) - Create
@spawnto validate captures toThreads.@spawn(#15) (@MilesCranmer)
v0.1.2
BorrowChecker v0.1.2
Merged pull requests:
- feat: overload
adjointandtranspose(#12) (@MilesCranmer)
v0.1.1
v0.1.0
BorrowChecker v0.1.0
Breaking changes
None.
Features
New function overloads for various methods in Base, including rand. The RNG object passed must be a mutable.
v0.0.13
BorrowChecker v0.0.13
Breaking changes
None
New features
This version introduces the @bc macro to simplify function calls within a BorrowChecker.jl context, by automatically creating temporary borrows.
Consider a function requiring specific borrows:
function process_items(
config::OrBorrowed{Dict},
data::OrBorrowedMut{Vector{Int}},
threshold::Int
)
# ... implementation ...
end
@own settings = Dict("enabled" => true)
@own :mut numbers = [1, 5, 2, 8, 3]Previously, passing references to objects required manual lifetime and reference management:
len = @lifetime lt begin
@ref ~lt r_settings = settings
@ref ~lt :mut r_numbers = numbers
process_items(r_settings, r_numbers, 3)
endWith @bc, the call becomes much more concise:
len = @bc process_items(settings, @mut(numbers), 3)@bc automatically creates an immutable borrow for settings and, guided by @mut, performs a mutable borrow for numbers. The integer 3 is passed directly. The lifetime of these references is held only for the duration of the process_items call, after which, the references are no longer available. In other words, it basically just expands to the @lifetime block above!
This significantly reduces boilerplate. Arguments already Borrowed/BorrowedMut or non-owned types are passed unchanged. Keyword arguments are supported, but splatting (...) is not yet implemented. Includes tests too.
Merged pull requests:
- Simplify creation of temporary borrows with
@bc(#10) (@MilesCranmer)
Closed issues:
- Automatically insert lifetimes (#7)
v0.0.12
BorrowChecker v0.0.12
Breaking changes
- Remove
@managedmacro, because Cassette.jl is not well-supported in recent Julia versions.
Closed issues:
- Delete
@set(#8)