Name

SPVM - SPVM Language

Description

SPVM is a statically typed programming language that has Perl-like syntax.

SPVM has not yet reached a stable release of version 1.0. For now, there is currently no policy to keep the backward compatibility.

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]);

Features

Documents

Loading SPVM Class

# Load a SPVM class
use SPVM 'SomeClass';

# Load only SPVM module
use SPVM ();

The use statement loads a SPVM class.

A SPVM class is loaded and is bound to a Perl module.

The bound Perl class 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 class 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 class 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 class compiler and linker are forced.

This setting has a higher priority than the force field of the SPVM::Builder::Config module.

Repository

SPVM - Github

Author

Yuki Kimoto <kimoto.yuki@gmail.com>

Core Developers

moti<motohiko.ave@gmail.com>

Contributors

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 69:

Unknown directive: =over2

Around line 71:

'=item' outside of any '=over'

Around line 81:

alternative text 'C/C++ binding' contains non-escaped | or /