Skip to content

Fix #13: math: Use a math.* namespace#30

Open
leftibot wants to merge 2 commits intoChaiScript:masterfrom
leftibot:fix/issue-13-math-use-a-math-namespace
Open

Fix #13: math: Use a math.* namespace#30
leftibot wants to merge 2 commits intoChaiScript:masterfrom
leftibot:fix/issue-13-math-use-a-math-namespace

Conversation

@leftibot
Copy link
Copy Markdown

Automated fix by @leftibot.

What changed

Fix #13: Add math.* namespace for Lua-style access to math 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

Files

 include/chaiscript/extras/math.hpp | 114 +++++++++++++++++++++++++++++++++++++
 tests/catch.hpp                    |   7 ++-
 tests/math.cpp                     |  31 ++++++++++
 3 files changed, 149 insertions(+), 3 deletions(-)

Closes #13

Triggered by @lefticus.

…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
Copy link
Copy Markdown
Member

@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
Copy link
Copy Markdown
Author

Addressed review feedback from @lefticus. New commits:

23008f2 Address review: Use ChaiScript namespaces instead of global math object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

math: Use a math.* namespace

2 participants