Uh oh!
There was an error while loading. Please reload this page.
Fix #13: math: Use a math.* namespace - #30
Conversation
…functions Register all math functions under a `math` namespace object using ChaiScript's Dynamic_Object system via Module::eval. Functions remain accessible as bare names (e.g., `cos(0.5)`) for backward compatibility, and are now also accessible as `math.cos(0.5)`, similar to Lua's math library. Also fixes Catch2 SIGSTKSZ compatibility with newer glibc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lefticus
commented
Apr 14, 2026
@leftibot update this to actually use namespaces instead of some global math object |
Upgrade ChaiScript from 5.8.6 to 6.1.0 to use its native namespace
support. Replace the Dynamic_Object/math_type class hack with proper
namespace("math") + function assignment, which is the idiomatic way
to create namespaces in ChaiScript 6.x. Update test files for the
6.x ChaiScript constructor API (stdlib is now included by default).
Requested by @lefticus in PR ChaiScript#30 review.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>leftibot
commented
Apr 14, 2026
Addressed review feedback from @lefticus. New commits: |
Uh oh!
There was an error while loading. Please reload this page.
| isunordered<bool, long double, long double>(m); | ||
| // Create math namespace | ||
| m->eval("namespace(\"math\")"); |
There was a problem hiding this comment.
May be good to document the libraries available in the readme.
There was a problem hiding this comment.
@leftibot create/update readme to track the capabilities of this project
Replace the script-level namespace("math") + lambda-wrapping hack with
chai.register_namespace(), ChaiScript's native namespace API. Functions
are now attached directly as Namespace attributes instead of being
wrapped in ChaiScript functions that forward to globals. The namespace
is registered lazily so its contents are only built when import("math")
is called.
Requested by @lefticus in PR ChaiScript#30 review.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>leftibot
commented
Apr 16, 2026
Addressed review feedback from @lefticus. New commits: |
lefticus
commented
Apr 16, 2026
Expand the README to track all modules and their capabilities: - Document both math APIs: bootstrap() for flat globals and bootstrap_namespace() for math.* namespace access. - List every math function by category, marking advanced functions gated by CHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED. - Flesh out the string_methods section with the full method list. - Document the types and operators registered by string_id. - Add a short build/test section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
leftibot
commented
Apr 16, 2026
Updated the The expanded README now covers:
If you'd rather keep this README change in a separate PR from the math-namespace work, I can split it out — let me know. |
RobLoach
left a comment
There was a problem hiding this comment.
I think the original functions are still there? I could be wrong though.
| math["isgreater"] = chaiscript::var(chaiscript::fun([](double x, double y){ return std::isgreater(x, y); })); | ||
| math["isgreaterequal"] = chaiscript::var(chaiscript::fun([](double x, double y){ return std::isgreaterequal(x, y); })); | ||
| math["isless"] = chaiscript::var(chaiscript::fun([](double x, double y){ return std::isless(x, y); })); | ||
| math["islessequal"] = chaiscript::var(chaiscript::fun([](double x, double y){ return std::islessequal(x, y); })); |
There was a problem hiding this comment.
Since these now live in the math namespace, would it make sense to remove the original ones.
leftibot
commented
Apr 16, 2026
Already done in this PR — see commit
If you'd prefer the README change land separately from the math-namespace work in this PR, say the word and I'll split it into its own PR. |
lefticus
commented
Apr 17, 2026
@leftibot resolve conflicts |
…se-a-math-namespace # Conflicts: # tests/catch.hpp
leftibot
commented
Apr 17, 2026
Addressed review feedback from @lefticus. New commits: |
Automated fix by @leftibot.
What changed
Files
Closes#13
Triggered by @lefticus.