Skip to content

Releases: MilesCranmer/BorrowChecker.jl

v0.2.1

27 Apr 21:05
fa1942c

Choose a tag to compare

BorrowChecker v0.2.1

Diff since v0.2.0

Merged pull requests:

v0.2.0

27 Apr 17:40
b189332

Choose a tag to compare

BorrowChecker v0.2.0

Diff since v0.1.5

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

Merged pull requests:

v0.1.5

26 Apr 17:19
ebc1c60

Choose a tag to compare

BorrowChecker v0.1.5

Diff since v0.1.4

Merged pull requests:

v0.1.4

25 Apr 20:41
f6cc68d

Choose a tag to compare

BorrowChecker v0.1.4

Diff since v0.1.3

Merged pull requests:

Closed issues:

  • Mutex feature (#16)

v0.1.3

13 Apr 23:00
629be8f

Choose a tag to compare

BorrowChecker v0.1.3

Diff since v0.1.2

Merged pull requests:

v0.1.2

12 Apr 23:33
a0b5798

Choose a tag to compare

BorrowChecker v0.1.2

Diff since v0.1.1

Merged pull requests:

v0.1.1

11 Apr 22:00
69c4784

Choose a tag to compare

BorrowChecker v0.1.1

Diff since v0.1.0

Merged pull requests:

v0.1.0

10 Apr 14:28
babda8a

Choose a tag to compare

BorrowChecker v0.1.0

Diff since v0.0.13

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

09 Apr 23:13
615e9c7

Choose a tag to compare

BorrowChecker v0.0.13

Diff since v0.0.12

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)
end

With @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:

Closed issues:

  • Automatically insert lifetimes (#7)

v0.0.12

08 Apr 18:43
b8a5429

Choose a tag to compare

BorrowChecker v0.0.12

Diff since v0.0.11

Breaking changes

  • Remove @managed macro, because Cassette.jl is not well-supported in recent Julia versions.

Closed issues:

  • Delete @set (#8)