From 082a8afdbafc00287b75845bc57bd18025333277 Mon Sep 17 00:00:00 2001 From: Nick Robinson Date: Mon, 15 Sep 2025 14:58:39 +0100 Subject: [PATCH 1/3] Rename `ScopedFunctor` -> `ScopedThunk` (per upstream) --- src/ScopedValues.jl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ScopedValues.jl b/src/ScopedValues.jl index ef7fe24..3568a37 100644 --- a/src/ScopedValues.jl +++ b/src/ScopedValues.jl @@ -1,6 +1,6 @@ module ScopedValues -export ScopedValue, with, @with, ScopedFunctor +export ScopedValue, with, @with, ScopedThunk if isdefined(Base, :ScopedValues) @@ -237,21 +237,22 @@ include("payloadlogger.jl") end # isdefined """ - ScopedFunctor(f) + ScopedThunk(f) Create a functor that records the current dynamic scope, i.e. all current `ScopedValue`s, along with `f`. When the functor is invoked, it runs `f` in the recorded dynamic scope. """ -struct ScopedFunctor{F} +struct ScopedThunk{F} f::F scope::Union{Nothing, Scope} - ScopedFunctor{F}(f) where {F} = new{F}(f, current_scope()) + ScopedThunk{F}(f) where {F} = new{F}(f, current_scope()) end -ScopedFunctor(f) = ScopedFunctor{typeof(f)}(f) -(sf::ScopedFunctor)() = @enter_scope sf.scope sf.f() +ScopedThunk(f) = ScopedThunk{typeof(f)}(f) +(sf::ScopedThunk)() = @enter_scope sf.scope sf.f() @deprecate scoped with +@deprecate ScopedFunctor ScopedThunk end # module ScopedValues From 557553a960e936da74fc18fa7f5d22d825189e6e Mon Sep 17 00:00:00 2001 From: Nick Robinson Date: Mon, 15 Sep 2025 15:14:35 +0100 Subject: [PATCH 2/3] Rename in tests too --- test/runtests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 6d28cc4..5c7208d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -130,18 +130,18 @@ end @test ret == 1.23 end -@testset "ScopedFunctor" begin +@testset "ScopedThunk" begin function check_svals() @test sval[] == 8 @test sval_float[] == 8.0 end sf = nothing @with sval=>8 sval_float=>8.0 begin - sf = ScopedFunctor(check_svals) + sf = ScopedThunk(check_svals) end sf() @with sval=>8 sval_float=>8.0 begin - sf2 = ScopedFunctor{Function}(check_svals) + sf2 = ScopedThunk{Function}(check_svals) end sf2() end From befc85bc0c35f4fd905bf60a2accf51d304db64a Mon Sep 17 00:00:00 2001 From: Nick Robinson Date: Mon, 15 Sep 2025 16:03:48 +0100 Subject: [PATCH 3/3] Update docstring --- src/ScopedValues.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScopedValues.jl b/src/ScopedValues.jl index 3568a37..bdc9aa8 100644 --- a/src/ScopedValues.jl +++ b/src/ScopedValues.jl @@ -239,8 +239,8 @@ end # isdefined """ ScopedThunk(f) -Create a functor that records the current dynamic scope, i.e. all current -`ScopedValue`s, along with `f`. When the functor is invoked, it runs `f` +Create a callable that records the current dynamic scope, i.e. all current +`ScopedValue`s, along with `f`. When the callable is invoked, it runs `f` in the recorded dynamic scope. """ struct ScopedThunk{F}