DEV Community

Yuki Kimoto - SPVM Author
Yuki Kimoto - SPVM Author

Posted on

SPVM improved Exchange API at v0.9684. Welcome to this easy world of type conversion!

SPVM improved Exchange API at v0.9684.

What is the Exchange API? It is a method for converting Perl data structures and SPVM data structures to each other.

SPVM is a statically typed language. Have you ever thought about the difficulties in passing an array of strings to a statically typed language?

Sounds easy? Please try it, this difficulty will be harder than you think. Strings are not just numbers. It must be dynamically allocated in memory. And when it comes to arrays, you need to allocate memory for the array, allocate memory for multiple strings, and assign them to the array. And finally, multiple strings must be deallocated and the array must be freed.

How many lines does this take? What happens if we repeat this over and over? More mistakes. More copy and paste. Your brain will get bored with the same thing over and over again.

# SPVM
class MyClass {
  static method foo ($strings : string[]) { ... }
}

# Perl
SPVM::MyClass->foo(["aaa", "bbb", "ccc"]);
Enter fullscreen mode Exit fullscreen mode

So you do not have to think about anything. Just pass the Perl string array reference as is.

This is just one example, but there are many automatic type conversions and methods that support conversions.

This is just one example, but there are many automatic type conversions and methods available in the Exchange API to support conversions.

Why don't you take a step into the world of SPVM's easy type conversion? The ease of type conversion will change the value of interactions between statically and dynamically typed languages.

Oldest comments (0)