NAME

Acme::ExtUtils::XSOne::Test::Calculator - A scientific calculator demonstrating ExtUtils::XSOne

VERSION

Version 0.01

SYNOPSIS

# Import functions directly from submodules
use Acme::ExtUtils::XSOne::Test::Calculator::Basic qw(add subtract multiply divide);
use Acme::ExtUtils::XSOne::Test::Calculator::Scientific qw(power sqrt_val);
use Acme::ExtUtils::XSOne::Test::Calculator::Trig qw(sin_val cos_val deg_to_rad);
use Acme::ExtUtils::XSOne::Test::Calculator::Memory qw(store recall ans clear);

# Basic arithmetic
my $sum  = add(2, 3);        # 5
my $diff = subtract(10, 4);  # 6
my $prod = multiply(3, 4);   # 12
my $quot = divide(15, 3);    # 5

# Scientific functions
my $pow  = power(2, 10);     # 1024
my $sqrt = sqrt_val(16);     # 4

# Trigonometry
my $sin = sin_val(deg_to_rad(90));  # 1.0

# Memory functions (shared state across all submodules!)
store(0, 42);
my $val  = recall(0);        # 42
my $last = ans();            # last result from any calculation
clear();                     # reset all memory and history

# Or use fully qualified names without importing
use Acme::ExtUtils::XSOne::Test::Calculator;

my $pi = Acme::ExtUtils::XSOne::Test::Calculator::pi();
my $e  = Acme::ExtUtils::XSOne::Test::Calculator::e();

DESCRIPTION

Acme::ExtUtils::XSOne::Test::Calculator is a demonstration module showing how to use ExtUtils::XSOne to create a multi-file XS module where all submodules share C-level state.

PACKAGES

All submodules support importing functions by name via use Module qw(func1 func2).

SHARED STATE

A key feature of this module is that all submodules share C-level state. This means:

  • The ans() function returns the last result from any calculation

  • Memory slots are accessible from all submodules

  • Calculation history records operations from all submodules

This is made possible by ExtUtils::XSOne, which combines multiple XS files into a single shared library.

AUTHOR

lnation <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by lnation.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)