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).
Acme::ExtUtils::XSOne::Test::Calculator::Basic
Basic arithmetic:
add,subtract,multiply,divide,modulo,negate,absolute,safe_divide,clamp,percentAcme::ExtUtils::XSOne::Test::Calculator::Scientific
Scientific operations:
power,sqrt_val,cbrt_val,nth_root,log_natural,log10_val,log_base,exp_val,factorial,ipow,safe_sqrt,safe_log,combination,permutationAcme::ExtUtils::XSOne::Test::Calculator::Trig
Trigonometry:
sin_val,cos_val,tan_val,asin_val,acos_val,atan_val,atan2_val,deg_to_rad,rad_to_deg,hypot_val,normalize_angle,sec_val,csc_val,cot_val,is_valid_asin_argAcme::ExtUtils::XSOne::Test::Calculator::Memory
Memory and history:
store,recall,clear,ans,history_count,get_history_entry,max_memory_slots,max_history_entries,is_valid_slot,used_slots,sum_all_slots,add_to
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 calculationMemory 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)