SPVM::D...e::Types(3)
๐ SPVM::D...e::Types(3) ๐
User Contributed Perl Documentation โ bestie, the manual-name situation is folded in right here at the top. โจ
๐ธ Name ๐ธ
SPVM::Document::Language::Types โ Types in the SPVM Language ๐
๐ฆ Description ๐ฆ
This document describes types in the SPVM language. Lowkey the whole type vibe check. ๐ซถ
โจ Data โจ
This section describes data.
A data is called value. Periodt. ๐
๐ข Number ๐ข
The value of numeric types is called number.
Normally, numbers are created by numeric literals.
# byte - 8bit signed integer
my $number = (byte)1;
# short - 16bit signed integer
my $number = (short)1;
# int - 32bit signed integer
my $number = 1;
# long - 64bit signed integer
my $number = 1L;
# float - 32bit floating point
my $number = 1.5f;
# double - 64bit floating point
my $number = 1.0;
A character created by character literal is a number of byte type.
# A number of byte type created by a character literal
my $char = 'a';
See the following section operations for numbers.
- Numeric Operators
- Numeric Comparison Operators
๐งฎ Internal Representation of Negative Integers ๐งฎ
Negative integers are represented by two's complement (https://en.wikipedia.org/wiki/Two%27s_complement). No cap, that's the bit-level lore. ๐
๐ String ๐
The value of string type is called string.
A string consists of characters of the byte type.
A string has its length.
A string is an object.
Normally, a string is created by a string literal or new_string_len operator.
# A string created by a string literal
my $string = "Hello";
my $char = $string->[0];
# A mutable string created by new_string_len operator
my $string = new_string_len 3;
$string->[0] = 'a';
See the following sections about operations for strings.
- length Operator
- String Concatenation Operator
- Character Get Operation
- Character Set Operation
- new_string_len Operator
- make_read_only Operator
- is_read_only Operator
- String Comparison Operators
- copy Operator
๐ Sting Native Level Representation ๐
At native level, the character just after the last character of the string is set to "\0", so the characters in the string can be used as a C language string.
# The characters in the string can be used as a C language string
void* obj_string = stack[0].oval;
const char* chars = env->get_chars(env, stack, obj_string);
if (strcmp(chars, "Hello") == 0) {
}
๐ Array ๐
The value of an array type is called array.
An array consists of a set of numbers, a set of objects, or a set of multi-numeric numbers.
An array has its length.
The elements of an array are arranged by index and the index starts from 0.
An array is an object.
Normally, an array is created by new Operator and an array initialization.
# An array created by new operator
my $numbers = new int[3];
$numbergers->[0] = 1;
my $strings = new string[3];
my $objects = new Point[3];
my $mulnum_numbers = new Complex_2d[3];
# An array created by an array initialization
my $numbers = [1, 2, 3];
All elements of an array can be got by for statement.
# for statement
for (my $i = 0; $i < @$numbers; $i++) {
my $number = $numbers->[$i];
}
# for-each statement
for my $number (@$numbers) {
}
See the following sections about operations for arrays.
- Creating Array in new Operator
- Array Initialization
- Array Length Operator
- Array Element Get Operation
- Array Element Set Operation
๐ Object ๐
The value of an object type is called object.
A string is an object.
An array is an object.
An object of class type has its fields. A field is a number or an object.
Normally, an object is created by new operator.
# An object created by new operator
my $point = new Point;
When an object is created, memory for the object is allocated in heap memory.
Created objects are destroyed by garbage collection.
See the following sections about operations for objects.
- new Operator
- dump Operator
- Field Get Operation
- Field Set Operation
- isa Operator
- is_type Operator
- type_name Operator
๐ Object Native Level Representation ๐
At native level, an object is a memory address.
void* obj_point = stack[0].oval;
๐ซถ Undefined Value ๐ซถ
The value of undef type is called undefined value.
An undefined value means the value is undefined.
An undefined value is created by undef operator.
undef
An undefined value is able to be assigned to an object type.
my $point : Point = undef;
Examples:
# Examples of undefined values
my $string : string = undef;
if (undef) {
}
my $message = "Hello";
if ($message == undef) {
}
๐ Undefined Value Native Level Representation ๐
At native level, an undefined value is equal to 0, normally a null pointer "NULL" defined in "stddef.h".
NULL
๐ง Multi-Numeric Number ๐ง
The value of a multi-numeric type is called multi-numeric number.
A multi-numeric number is a set of numbers of the same type.
my $z : Complex_2d;
$z->{re} = 1;
$z->{im} = 2;
See the following sections about operations for multi-numeric numbers.
- Multi-Numeric Field Get Operation
- Multi-Numeric Field Set Operation
๐ Reference ๐
The value of a reference type is called reference.
A reference has a referencing value.
A referencing value must be a number or a multi-numeric number
The reference operator "\" creates a reference.
my $number : int;
my $number_ref = \$number;
See the following sections about operations for multi-numeric numbers.
- Referenced Value Get Operation
- Referenced Value Set Operation
- Reference Operator
- Dereference Operator
- Referenced Multi-Numeric Field Get Operation
- Referenced Multi-Numeric Field Set Operation
โญ Reference Native Level Representation โญ
At native level, a reference is a memory address.
int32_t* num_ref = stack[0].iref;
๐ TYPES ๐
Okay so this whole section is the lowkey legend of types โ what they are, how theyโre written, and all the little rules attached to them. Letโs go, bestie ๐ซถ
โจ NUMERIC TYPES โจ
This section describes numeric types, periodt.
๐ข INTEGER TYPES ๐ข
This section describes integer types.
An integer type is a numeric type. No cap.
๐ byte Type
The byte type is the type for a signed 8-bit integer.
byte
The byte type is an integer type.
๐ short Type
The short type is the type for a signed 16-bit integer.
short
The short type is an integer type.
๐ int Type
The int type is the type for a signed 32-bit integer.
int
The int type is an integer type.
๐ long Type
The long type is the type for a signed 64-bit integer.
long
The long type is an integer type.
๐ฆ FLOATING POINT TYPES ๐ฆ
This section describes floating point types.
A floating point type is a numeric type.
๐ธ float Type
The float type is the type for 32bit floating point.
float
The float type is a floating point type.
๐ธ double Type
The double type is the type for 64bit floating point.
double
The double type is a floating point type.
๐ NUMERIC TYPES ORDER ๐
Numeric types have their order, and yes it matters.
The order is byte, short, int, long, float, double from smallest to largest. Slay ๐
๐งธ OBJECT TYPES ๐งธ
This section lists object types.
๐ string Type ๐
The string type is the type for strings.
string
The string type is an object type.
The string type can be qualified with the mutable type qualifier:
mutable string
string type has a to_string method and satisfies the Stringable interface.
The definition of the to_string method is as follows:
method to_string : string ();
This method returns itself.
Because string type satisfies the Stringable interface, it can be cast or assigned to the Stringable interface.
Moreover, array covariance is supported for the string type. For example, string[] can be cast or assigned to Stringable[], and string[][] can be cast or assigned to Stringable[][]. Iconic behavior, honestly ๐ฅ
๐๏ธ CLASS TYPES ๐๏ธ
A class type is the type for a class.
A class type is defined by class definition:
class CLASS_TYPE {
}
An object can be created from a class by a new operator.
Note: an interface type and a multi-numeric type are not a class type, even though these types are defined by class definition ๐
๐ข NUMERIC OBJECT TYPES ๐ข
A numeric object type is a class type that owns the corresponding field of a numeric type.
The List of Numeric Object Types:
๐ง INTERFACE TYPES ๐ง
An interface type is a type for an interface.
An interface type is defined by an interface definition:
class INTERFACE_TYPE : interface_t {
}
๐ ANY OBJECT TYPE ๐
Any object type object is the type to which any object type can be assigned.
object
Examples:
# Examples of any object type
my $object: object = new Foo;
๐ง BASIC TYPES ๐ง
A basic type is a type whose type dimension is 0 and that can be an element of an array.
The List of Basic Types:
- Numeric types
- Multi-numeric types
- Class types
- Interface types
- any object type
- string type
๐ซ๏ธ undef TYPE ๐ซ๏ธ
The undef type is the type of an undefined value.
๐ณ๏ธ void TYPE ๐ณ๏ธ
The void type is the type that represents a method defined by a method definition that does not return a return value.
void
๐ง ARRAY TYPES ๐ง
An array type is a type for an array. An array type consists of a basic type and a type dimension such as [], [][].
BASIC_TYPE[]..
([].. means one more [].)
Examples:
# Numeric array
int[]
double[]
# String array
string []
# Class array
Point[]
# Any object array
object[]
# 2 dimensional array
int[][]
# 3 dimensional array
int[][][]
An array type is an object type. Yup, arrays are objects here too ๐
Compilation Errors:
The dimension is less than or equal to 255. Otherwise, a compilation error occurs.
๐ข NUMERIC ARRAY TYPES ๐ข
A numeric array type is an array type of a numeric type.
The List of Numeric Array Types:
byte[]
short[]
int[]
long[]
float[]
double[]
๐ OBJECT ARRAY TYPES ๐
An object array type is an array type of an object type.
Examples:
Point[]
Point[][]
Stringable[]
string[]
object[]
๐ STRING ARRAY TYPE ๐
The string array type is the array type of the string type.
string[]
๐๏ธ CLASS ARRAY TYPES ๐๏ธ
A class array type is an array type of a class type.
Examples:
Int[]
Point[]
๐ง INTERFACE ARRAY TYPES ๐ง
An interface array type is an array type of an interface type.
Examples:
Stringable[]
Cloneable[]
๐ช MULTI-DIMENSIONAL ARRAY TYPES ๐ช
A multi-dimensional array type is an array type of an array type.
Examples:
int[][]
Int[][]
string[][][]
object[][]
A multi-dimensional array is created by the syntax of creating a multi-dimensional array of the new operator.
๐ธ MULTI-NUMERIC ARRAY TYPES ๐ธ
A multi-numeric array type is an array type of a multi-numeric type.
Examples:
Complex_2d[]
Complex_2f[]
๐ ANY OBJECT ARRAY TYPE ๐
The any object array type object[] is an array type to which any object array type can be assigned.
object[]
๐ MULTI-NUMERIC TYPES ๐
A multi-numeric type is a type for a multi-numeric number.
A multi-numeric type is defined by a multi-numeric type definition:
class MULNUM_TYPE : mulnum_t {
}
๐ช REFERENCE TYPES ๐ช
A reference type is a type for a reference.
TYPE*
A reference type consists of a type followed by *.
TYPE must be a numeric type or a multi-numeric type.
๐ข NUMERIC REFERENCE TYPES ๐ข
A numeric reference type is a reference type of a numeric type.
The List of Numeric Reference Types:
byte*
short*
int*
long*
float*
double*
๐ธ MULTI-NUMERIC REFERENCE TYPES ๐ธ
A multi-numeric reference type is a reference type of a multi-numeric type.
MULNUM_TYPE*
Examples:
Complex_2d*
Complex_2f*
๐ TYPE QUALIFIERS ๐
A type qualifier qualifies a type.
QUALIFIER TYPE
The QUALIFIER qualifies the type TYPE.
๐
mutable TYPE QUALIFIER ๐
The mutable type qualifier qualifies string type.
mutable string;
The string of string type with the mutable type qualifier is able to be set a character.
my $string = (mutable string)copy "abc";
$string->[0] = 'd';
๐ซ TYPE INITIAL VALUE ๐ซ
The value of a type is initialized by its type initial value.
The List of Type Initial Values:
๐ TYPE WIDTH ๐
The type width is the length of runtime stack of the type.
If the type is a multi-numeric type, the type width is the length of the fields; otherwise it is 1.
๐ฅ UNION TYPE ๐ฅ
A union type expresses the logical OR of types.
TYPE1|TYPE2|TYPEn
A union type is treated as any object type object.
Examples:
my $union = (string|string[])undef;
method : foo ($union : string|string[]) {
}
๐งฌ GENERIC TYPE ๐งฌ
The generic type is:
TYPE of ELEMENT_TYPE
TYPE is a type.
ELEMENT_TYPE is a type.
A generic type is treated as TYPE. ELEMETN_TYPE is ignored in compilation time type checks.
ELEMETN_TYPE is only used for the type cast for element type.
Examples:
# Examples of generic types
has points : List of Point;
has hash_of_list_of_point : Hash of List of Point;
our $POINTS : List of Point;
my $points : List of Point;
static method foo : List of Point ($arg : List of Point) { ... }
my $replace : object of string|Regex::Replacer;
Compilation Errors:
If the type specified as the generic type is not found, a compilation error occurs.
๐ ASSIGNMENT REQUIREMENT ๐
Okay so the assignment requirement is literally the requirement whether one type is able to be assigned to another type. Bestie, what does it even mean to assign one type to another type?
Typically, it's enough to think about a case where a value of a type TYPE_FROM is assigned to a variable of a type TYPE_TO.
my $value : TYPE_FROM;
my $var : TYPE_TO = $value;
Abstracting this, type-to-type assignment is defined.
TYPE_TO = TYPE_FROM
Note: this is a concept, not an actual syntax. Do not go looking for this line in your code, she's metaphorical ๐
Some assignments perform a data conversion.
In the following description, the word "Type" is omitted when it is obvious.
๐ธ Assignment Requirement to Numeric ๐ธ
โจ Assignment Requirement from Numeric to Numeric โจ
- To Larger: (the page just drops this line and moves on โ iconic minimalism ๐ )
- To Smaller: (same vibe, no extra deets)
"Conditional Yes" means the following:
- For Integral Types: If the value of
TYPE_FROMis represented by an integer literal and between the max and minimal value of the type ofTYPE_TO, Yes, otherwise No. - For Floating Point types: If the value of
TYPE_FROMis represented by a floating point literal, Yes, otherwise No.
โจ Assignment Requirement from NumericObject to Numeric โจ
No extra conditions listed under this one โ heading only, periodt.
โจ Assignment Requirement from Any Object to Numeric โจ
Also no extra conditions listed here โ she said what she said.
โจ Assignment Requirement from Other to Numeric โจ
NumericX is a numeric type.
๐ธ Assignment Requirement to Multi-Numeric ๐ธ
Multi-NumericX is a multi-numeric type.
๐ฆ Assignment Requirement to Referenece ๐ฆ
ReferenceX is a reference type.
Yes, the heading says Referenece โ we are keeping the typo exactly as the page serves it. Quirky queen behavior ๐
๐ธ Assignment Requirement to String ๐ธ
NumericX is a numeric type.
๐ธ Assignment Requirement to NumericObject ๐ธ
NumericObjectX is a numeric object type.
NumericX is a numeric type.
๐ธ Assignment Requirement to Class ๐ธ
ClassX is a class type.
SuperClassX is a super class of ClassX.
๐ธ Assignment Requirement to Interface ๐ธ
InterfaceX is an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfies the interface requirement of InterfaceX.
๐ธ Assignment Requirement to Any Object ๐ธ
ObjectX is an object type.
NumericX is a numeric type.
๐ธ Assignment Requirement to undef ๐ธ
X is a type.
๐ธ Assignment Requirement to void ๐ธ
X is a type.
๐ธ Assignment Requirement to Numeric Array ๐ธ
NumericX is a numeric type.
๐ธ Assignment Requirement to Multi-Numeric Array ๐ธ
Multi-NumericX is a multi-numeric type.
๐ธ Assignment Requirement to String Array ๐ธ
No extra notes under this heading โ she's just here to vibe.
๐ธ Assignment Requirement to Class Array ๐ธ
ClassX is a class type.
SuperClassX is a super class of ClassX.
๐ธ Assignment Requirement to Interface Array ๐ธ
InterfaceX is an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfies the interface requirement of InterfaceX.
๐ธ Assignment Requirement to Any Object Array ๐ธ
ObjectX is an object type.
"[].." is one or more "[]".
๐ Assignment Requirement to Multi-Dimensional Array ๐
X is a type.
"[].." is one or more "[]".
D means its type dimension is greater than or equal to 2.
X[]..D is a multi-dimensional array.
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfies the interface requirement of InterfaceX.
๐ซ CAST REQUIREMENT ๐ซ
The cast requirement is the requirement whether one type is able to be cast to another type.
What does it mean to cast one type to another type? Typically, it's enough to think about a case where a value of a type TYPE_FROM is casted to TYPE_TO.
my $value : TYPE_FROM;
(TYPE_TO)$value;
Abstracting this, type-to-type cast is defined.
(TYPE_TO)TYPE_FROM
Note: this is a concept, not an actual syntax. Again โ concept only, no cap ๐ซถ
Some type casts perform a data conversion.
Some type casts perform a data check.
In the following description, the word "Type" is omitted when it is obvious.
๐ธ Cast Requirement to Numeric ๐ธ
โจ Cast Requirement from Numeric to Numeric โจ
- To Larger: (the page just says this and moves on โ mysterious and chic ๐ )
- To Smaller: (same energy, no extra details)
โจ Cast Requirement from NumericObject to Numeric โจ
No extra conditions listed under this one โ heading only.
โจ Cast Requirement from Any Object to Numeric โจ
NumericX is a numeric type.
โจ Cast Requirement from Other to Numeric โจ
NumericX is a numeric type.
๐ธ Cast Requirement to Multi-Numeric ๐ธ
Multi-NumericX is a multi-numeric type.
๐ฆ Cast Requirement to Referenece ๐ฆ
ReferenceX is a reference type.
Again, Referenece is exactly how the page spells it. We are not fixing her, we are respecting her ๐
๐ธ Cast Requirement to String ๐ธ
NumericX is a numeric type.
๐ธ Cast Requirement to NumericObject ๐ธ
NumericObjectX is a numeric object type.
NumericX is a numeric type.
๐ธ Cast Requirement to Class ๐ธ
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is an interface type.
๐ธ Cast Requirement to Interface ๐ธ
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is an interface type.
InterfaceY is an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfies the interface requirement of InterfaceX.
๐ธ Cast Requirement to Any Object ๐ธ
ObjectX is an object type.
NumericX is a numeric type.
๐ธ Cast Requirement to Numeric Array ๐ธ
NumericX is a numeric type.
๐ธ Cast Requirement to Multi-Numeric Array ๐ธ
Multi-NumericX is a multi-numeric type.
๐ธ Cast Requirement to String Array ๐ธ
No extra notes here either โ just the heading, serving looks.
๐ธ Cast Requirement to Class Array ๐ธ
ClassX is a class type.
SuperClassX is a super class of ClassX.
๐ธ Cast Requirement to Interface Array ๐ธ
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is an interface type.
InterfaceY is an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfies the interface requirement of InterfaceX.
๐ธ Cast Requirement to Any Object Array ๐ธ
ObjectX is an object type.
"[].." is one or more "[]".
๐ Cast Requirement to Multi-Dimensional Array ๐
X is a type.
"[].." is one or more "[]".
D means its type dimension is greater than or equal to 2.
X[]..D is a multi-dimensional array.
ClassX is a class type.
SuperClassX is a super class of ClassX.
InterfaceX is an interface type.
InterfaceSatisfiedX is a class type or an interface type that satisfies the interface requirement of InterfaceX.
๐ INTERFACE REQUIREMENT ๐
The interface requirement is the requirement whether an object type is able to be assigned to an interface type.
INTERFACE_TYPE_TO = OBJECT_TYPE_FROM
This is the same concept as type-to-type assignment explained in Assignment Requirement.
INTERFACE_TYPE_TO must be an interface type.
OBJECT_TYPE_FROM must be a class type or an interface type.
The following check is performed on every instance method of OBJECT_TYPE_FROM.
If an instance method of INTERFACE_TYPE_TO has the "required" method attribute, OBJECT_TYPE_FROM or one of its super classes must have a method with the same name.
If OBJECT_TYPE_FROM or one of its super classes has an instance method (this is named METHOD_FROM) with the same name as an instance method of INTERFACE_TYPE_TO, METHOD_FROM must be an instance method and satisfy interface method requirement.
๐ Interface Method Requirement ๐
The interface method requirement is the requirement whether a method is able to be assigned to an interface method.
INTERFACE_METHOD_TO = METHOD_FROM
This is a concept that converts the type-to-type assignment explained in Assignment Requirement to method-to-method assignment.
INTERFACE_METHOD_TO must be an instance method.
METHOD_FROM must be an instance method.
The length of the arguments of the method of the INTERFACE_METHOD_TO type must be greater than or equal to the length of the required arguments the method of the INSTANT_METHOD_TYPE_FROM type.
Every argument other than at 0 index of the method of the INSTANT_METHOD_TYPE_FROM must satisfy assignment requirement to the argument as the same index of the method of the INTERFACE_METHOD_TO without a data conversion and with interface exactly matched.
The return type of the method of the INSTANT_METHOD_TYPE_FROM must satisfy assignment requirement to the return type of the method of the INTERFACE_METHOD_TO without a data conversion and with interface exactly matched.
๐ See Also ๐
SPVM::Document::Language::ClassSPVM::Document::Language::OperatorsSPVM::Document::Language::StatementsSPVM::Document::LanguageSPVM::Document
๐ Copyright & License ๐
Copyright (c) 2023 Yuki Kimoto
MIT License
And that's the whole page, bestie! This lil' masterpiece is from perl v5.42.2, dated 2026-02-03, and it's the SPVM::D...e::Types(3) manpage. Mwah ๐โจ
๐ฆ where this page comes from
- alpine 3.24: spvm-doc 0.990125-r0 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms