feat: per-context giac_eval, drive wrapper_version from meson#4
Merged
Conversation
Closes #2, closes #3. #3: Add a new free-function overload Gen giac_eval(const std::string& expr, GiacContext& ctx); that mirrors the existing `giac_eval(expr)` but routes the parse and eval through `ctx.impl_->ctx` instead of the thread-local singleton. Two distinct `GiacContext` instances therefore observe independent `:=` bindings and configuration state. This is what `Giac.jl`'s `giac_eval(expr, ctx::GiacContext)` signature has been advertising all along — until now, the Julia-side `ctx` was silently ignored at the C++ layer because no context-aware Gen-returning binding existed. Bound to Julia under the same name with `static_cast` to disambiguate the two free-function overloads (`giac_eval(expr)` and `giac_eval(expr, ctx)`), so CxxWrap exposes both as `giac_eval` methods that dispatch on arity. Covered by new tests: - C++: tests/cpp/test_context.cpp::giac_eval_with_context_returns_gen - Julia: tests/julia/test_context.jl "giac_eval(expr, ctx) — returns Gen and isolates bindings" #2: Drive `get_wrapper_version()` from `meson.project_version()` at build time via `-DWRAPPER_VERSION="$ver"` set by `add_project_arguments`, so the version string no longer needs to be maintained in two places. Bumped 0.5.0 → 0.6.0 for the new API surface (minor bump per SemVer; no breaking change — existing single-arg `giac_eval` is preserved). Updated the C++ and Julia version tests to accept any SemVer-shaped value rather than pinning a literal. `meson test -C builddir`: 6/6 green locally.
Adds a C++ regression test that reproduces the exact scenario reported in issue #3: binding y := 42 in one GiacContext and then calling desolve(diff(y,t)=cos(t), t, y) in a fresh, independent GiacContext must succeed (returns c_0+sin(t)). Manually verified that running the same desolve in the same context as the binding still throws "GIAC evaluation error: Dependent variable assigned. Run purge(y)" — so the test is a real regression guard against context isolation breaking in the future. README gains one bullet under "Features" naming per-context evaluation and linking back to the issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2, closes #3.
#3 — Per-context
giac_evalreturning aGenAdds a new free-function overload
mirroring the existing
giac_eval(expr)but routing parse + eval throughctx.impl_->ctxinstead of the thread-local singleton. Two distinctGiacContextinstances now observe independent:=bindings and configuration state.This is the missing piece that
Giac.jl'sgiac_eval(expr, ctx::GiacContext)signature has been advertising all along — the Julia-sidectxwas silently ignored at the C++ layer because no context-aware Gen-returning binding existed. Once this lands, Giac.jl's_giac_eval_stringcan passctx_ptrthrough and finally honour the documented isolation contract (the!!! warningblocks just added in Giac.jl#32 can be removed in the follow-up).Both overloads are bound to Julia under the same
giac_evalname withstatic_castto disambiguate; CxxWrap exposes them as arity-dispatched methods.#2 — Drive
get_wrapper_version()from mesonget_wrapper_version()had"0.1.0"hardcoded whilemeson.buildclaimed0.5.0. Now driven frommeson.project_version()at build time viaso bumps happen in exactly one place. Bumped 0.5.0 → 0.6.0 for the new API surface (minor bump per SemVer; existing single-arg
giac_evalis preserved).Test plan
meson test -C builddir— 6/6 green locally (test_eval, test_context, test_gen, test_warnings, test_predicates, test_extraction)tests/cpp/test_context.cpp::giac_eval_with_context_returns_gentests/julia/test_context.jl "giac_eval(expr, ctx) — returns Gen and isolates bindings""0.1.0"