Name
SPVM - SPVM Language
Description
SPVM is a statically typed programming language with the syntax of Perl.
SPVM has not yet reached a stable release of version 1.0. For now, backward compatibility of methods and features will not be kept.
Usage
A class of SPVM:
# lib/SPVM/MyMath.spvm
class MyMath {
static method sum : int ($nums : int[]) {
my $total = 0;
for (my $i = 0; $i < @$nums; $i++) {
$total += $nums->[$i];
}
return $total;
}
}
Calling a SPVM method from Perl:
# sum.pl
use FindBin;
use lib "$FindBin::Bin/lib";
use SPVM 'MyMath';
# Call method
my $total = SPVM::MyMath->sum([3, 6, 8, 9]);
Documents
Tutorial - SPVM Tutorial
Language Specification - SPVM Language Specification
Standard Modules - SPVM Standard Modules
ExchangeAPI - Exchange APIs
Native Module - Native Module
Native APIs - Native APIs
Resource - Resource
spvmcc - Creating Executable File
spvmdist - Creating SPVM Distribution
Benchmark - SPVM Performance Benchmarks
use
use SPVM;
use SPVM 'SomeClass';
Loads the SPVM module.
If a module name of SPVM is given as the first argument, the SPVM module is loaded and is bound to a Perl module.
The bound Perl module name is prefixed with SPVM::
.
Exceptions:
If the SPVM module cannot be loaded, an exception is thrown.
Examples:
use SPVM 'Int';
my $int_object = SPVM::Int->new(3);
my $value = $int_object->value.
Functions
api
my $api = SPVM::api();
Gets the global SPVM::ExchangeAPI object for this Perl interpreter.
Environment Variables
If an environment variable is an empty string, it is treated as an undefined value.
SPVM_BUILD_DIR
A directory for files generated by the compiler and linker.
C source codes for precompilation, dynamic link libraries and object files are stored into this directory.
These files are output when attempting to build a module containing methods with the native
attribute or the precompile
attribute.
If these files are output and the directory given by the SPVM_BUILD_DIR
environment variable does not exist, an exception is thrown. Examples:
# bash
export SPVM_BUILD_DIR=~/.spvm_build
# csh
setenv SPVM_BUILD_DIR ~/.spvm_build
SPVM_CC_DEBUG
If the SPVM_CC_DEBUG
environement variable is a true value of Perl, debug messages and messages from the SPVM native module compiler and linker are printed to stderr.
SPVM_CC_QUIET
If the SPVM_CC_QUIET
environement variable is a true value of Perl, messages the SPVM native module compiler and linker are not printed to stderr.
If it is defined and a false value of Perl, the messages are printed.
This setting has a higher priority than the quiet field of the SPVM::Builder::Config module.
SPVM_CC_FORCE
If the SPVM_CC_FORCE
environement variable is a true value of Perl, the compilation and link by the SPVM native module compiler and linker are forced.
This setting has a higher priority than the force field of the SPVM::Builder::Config module.
Repository
Author
Yuki Kimoto <kimoto.yuki@gmail.com>
Core Developers
moti<motohiko.ave@gmail.com>
Contributors
Mohammad S Anwar
akinomyoga
NAGAYASU Shinya
Reini Urban
chromatic
Kazutake Hiramatsu
Yasuaki Omokawa
Suman Khanal
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License