Skip to content

Commit bc3906f

Browse files
committed
Initial implementation
1 parent 823efce commit bc3906f

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ uuid = "b9860ae5-e623-471e-878b-f6a53c775ea6"
33
authors = ["Takafumi Arakaki <aka.tkf@gmail.com> and contributors"]
44
version = "0.1.0"
55

6+
[deps]
7+
ContextVariablesX = "6add18c4-b38d-439d-96f6-d6bc489c04c5"
8+
69
[compat]
710
julia = "1"
811

src/FLoopsBase.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
module FLoopsBase
22

3-
# Write your package code here.
3+
using ContextVariablesX
4+
@contextvar EXTRA_STATE_VARIABLES::Union{Vector{Union{Symbol,Expr}},Nothing} = nothing
5+
6+
function with_extra_state_variables(f, variables)
7+
current_vars = copy(something(EXTRA_STATE_VARIABLES[], Union{Symbol,Expr}[]))
8+
new_vars = append!(current_vars, variables)
9+
with_context(f, EXTRA_STATE_VARIABLES => new_vars)
10+
end
411

512
end

0 commit comments

Comments
 (0)