Skip to content
Yuki Kimoto - SPVM - Perl Club edited this page Apr 5, 2023 · 19 revisions

SPVM FAQs.

Backword Compatibility

How developers can keep binary compatibility of SPVM

SPVM is designed to keep binary compatibility.

Even if the SPVM language itself is upgraded, previously installed SPVM modules and applications will work correctly without experiencing segmentation faults.

However, whether or not SPVM developers will actually keep binary compatibility is pending until version 1.0.

Here is how developers can keep binary compatibility after version 1.0 is reached.

Requirement 1: Do not change the SPVM operation code implementation defined in spvm_implement.h

Binary compatibility is not kept if the implementation of the SPVM operation code defined in spvm_implement.h is changed.

This is because the precompiled code contains the implementation of the operation code defined in spvm_implement.h.

On the other hand, implementation changes in spvm_api.c will not affect binary compatibility.

Requirement 2: Do not change the Native API order defined in spvm_native.h

Binary compatibility is not be kept if the order of Native APIs defined in spvm_native.h is changed (i.e., the IDs are changed in the documentation).

License

Why was the license of SPVM changed to the MIT license?

Because the MIT license is the open source license that most developers know and understand.

The Perl Artistic License is a great open source license, but its biggest problem is that it is not well known outside of Perl developers.

Syntax

What is the advantage the local variable name has sigil($)?

Because the local variable name ($foo) has a sigil, it will not conflict with keyword names, class names, method names, or field names.

When declaring local variables, you can write programs without worrying about name conflicts.

You can write programs without worrying about name conflicts with keywords that may be added in the future.

Class variable names will conflict with local variable names, but this can be conventionally avoided by using upper case for class variable names($FOO) and lower case for local variable names($foo).

String

What is the character code of the SPVM string?

The SPVM string are simply a sequence of bytes of the string type. The sequence of bytes is exactly the same as the byte[] type.

A string are supposed to be represented in UTF-8, which is just a sequence of bytes.

Please tell me about the conversion between a Perl string and a SPVM string.

A Perl string is converted to a SPVM string by the new_string method in the SPVM::ExchangeAPI class.

Whether the UTF-8 flag is set in the Perl string or not, the sequence of bytes stored in the PV slot of Perl's SV type is copied to the SPVM string.

A SPVM string is converted to a SPVM::BlessedObject::String object when is is returned to Perl.

A SPVM::BlessedObject::String has the SPVM string as it is.

If you want to convert it to a Perl string with UTF-8 flag, use the to_string method in the SPVM::BlessedObject::String class or use "" overloading, like "$blessed_object_string". The utf8::decode function is called and the UTF-8 flag is set to the Perl string.

If you want to treat it as a sequence of bytes, use the to_bin method in the SPVM::BlessedObject::String class.

Clone this wiki locally