How does SPVM resolve the problems of Perl numeric operations?
How does SPVM resolve the problems of Perl numeric operations?
I hear Perl have the problems of numeric operation.
I realized this problems, and try to resolve them using SPVM. (SPVM is yet experimental release).
What is SPVM?
SPVM is a programing language to provide fast static-typed numeric operation and array operations into Perl.
I'm writing SPVM Language Specification now.
Do you want to use static typed numeric arrays(byte[], short[], int[], long[], float[], double[]) in Perl? You can write these using SPVM.
# lib/SPVM/MyArray.spvm class MyArray { static method array_add_int : int[] ($array1 : int[], $array2 : int[]) { my $array_length = @$array1; my $array_out = new int[$array_length]; for (my $i = 0; $i < $array_length; $i++) { $array_out->[$i] = $array1->[$i] + $array2->[$i]; } return $array_out; } }
# my_array.pluse FindBin;
use lib "$FindBin::Bin/lib";
use SPVM 'MyArray';my $array_out = SPVM::MyArray->array_add_int([1, 2, 3], [4, 5, 6]);
# 5, 7, 9
warn "@$array_out";
A huge piece of work Kimoto-san, well done. Do you anticipate that user generated classes (.spvm files) to be located in /lib/SPVM/ or can they be in any directory?
Hi, Saif
.spvm files can be located in any directory.
/path/SPVM/MyArray.spvm
foo/bar/SPVM/MyArray.spvm
SPVM directory is always needed because "SPVM::" is the part of the Perl module name.