| 1 | =head1 Name | ||
| 2 | |||
| 3 | SPVM::Document::Language::Types - Types in the SPVM Language | ||
| 4 | |||
| 5 | =head1 Description | ||
| 6 | |||
| 7 | This document describes types in the SPVM language. | ||
| 8 | |||
| 9 | =head1 Data | ||
| 10 | |||
| 11 | This section describes data. | ||
| 12 | |||
| 13 | A data is called value. | ||
| 14 | |||
| 15 | =head2 Number | ||
| 16 | |||
| 17 | The value of L<numeric types|/"Numeric Types"> is called number. | ||
| 18 | |||
| 19 | Normally, numbers are created by L<numeric literals|SPVM::Document::Language::Tokenization/"Numeric Literals">. | ||
| 20 | |||
| 21 | # byte - 8bit signed integer | ||
| 22 | my $number = (byte)1; | ||
| 23 | |||
| 24 | # short - 16bit signed integer | ||
| 25 | my $number = (short)1; | ||
| 26 | |||
| 27 | # int - 32bit signed integer | ||
| 28 | my $number = 1; | ||
| 29 | |||
| 30 | # long - 64bit signed integer | ||
| 31 | my $number = 1L; | ||
| 32 | |||
| 33 | # float - 32bit floating point | ||
| 34 | my $number = 1.5f; | ||
| 35 | |||
| 36 | # double - 64bit floating point | ||
| 37 | my $number = 1.0; | ||
| 38 | |||
| 39 | A character created by L<character literal|SPVM::Document::Language::Tokenization/"Character Literal"> is a number of byte type. | ||
| 40 | |||
| 41 | # A number of byte type created by a character literal | ||
| 42 | my $char = 'a'; | ||
| 43 | |||
| 44 | See the following section operations for numbers. | ||
| 45 | |||
| 46 | =over | ||
| 47 | |||
| 48 | =item * L<Numeric Operators|SPVM::Document::Language::Operators/"Numeric Operators"> | ||
| 49 | |||
| 50 | =item * L<Numeric Comparison Operators|SPVM::Document::Language::Operators/"Numeric Comparison Operators"> | ||
| 51 | |||
| 52 | =back | ||
| 53 | |||
| 54 | =head3 Internal Representation of Negative Integers | ||
| 55 | |||
| 56 | Negative integers are represented by L<two's complement|https://en.wikipedia.org/wiki/Two%27s_complement>. | ||
| 57 | |||
| 58 | =head2 String | ||
| 59 | |||
| 60 | The value of L<string type|/"string Type"> is called string. | ||
| 61 | |||
| 62 | A string consists of characters of the C<byte> type. | ||
| 63 | |||
| 64 | A string has its length. | ||
| 65 | |||
| 66 | A string is an L<object|/"Object">. | ||
| 67 | |||
| 68 | Normally, a string is created by a L<string literal|SPVM::Document::Language::Tokenization/"String Literal"> or L<new_string_len operator|SPVM::Document::Language::Operators/"new_string_len Operator">. | ||
| 69 | |||
| 70 | # A string created by a string literal | ||
| 71 | my $string = "Hello"; | ||
| 72 | my $char = $string->[0]; | ||
| 73 | |||
| 74 | # A mutable string created by new_string_len operator | ||
| 75 | my $string = new_string_len 3; | ||
| 76 | $string->[0] = 'a'; | ||
| 77 | |||
| 78 | See the following sections about operations for strings. | ||
| 79 | |||
| 80 | =over 2 | ||
| 81 | |||
| 82 | =item * L<length Operator|SPVM::Document::Language::Operators/"length Operator"> | ||
| 83 | |||
| 84 | =item * L<String Concatenation Operator|SPVM::Document::Language::Operators/"String Concatenation Operator"> | ||
| 85 | |||
| 86 | =item * L<Character Get Operation|SPVM::Document::Language::Operators/"Character Get Operation"> | ||
| 87 | |||
| 88 | =item * L<Character Set Operation|SPVM::Document::Language::Operators/"Character Set Operation"> | ||
| 89 | |||
| 90 | =item * L<new_string_len Operator|SPVM::Document::Language::Operators/"new_string_len Operator"> | ||
| 91 | |||
| 92 | =item * L<make_read_only Operator|SPVM::Document::Language::Operators/"make_read_only Operator"> | ||
| 93 | |||
| 94 | =item * L<is_read_only Operator|SPVM::Document::Language::Operators/"is_read_only Operator"> | ||
| 95 | |||
| 96 | =item * L<String Comparison Operators|SPVM::Document::Language::Operators/"String Comparison Operators"> | ||
| 97 | |||
| 98 | =item * L<copy Operator|SPVM::Document::Language::Operators/"copy Operator"> | ||
| 99 | |||
| 100 | =back | ||
| 101 | |||
| 102 | =head3 Sting Native Level Representation | ||
| 103 | |||
| 104 | At L<native level|SPVM::Document::NativeClass>, the character just after the last character of the string is set to C<\0>, so the characters in the string can be used as a C language string. | ||
| 105 | |||
| 106 | # The characters in the string can be used as a C language string | ||
| 107 | void* obj_string = stack[0].oval; | ||
| 108 | const char* chars = env->get_chars(env, stack, obj_string); | ||
| 109 | if (strcmp(chars, "Hello") == 0) { | ||
| 110 | |||
| 111 | } | ||
| 112 | |||
| 113 | =head2 Array | ||
| 114 | |||
| 115 | The value of an L<array type|/"Array Types"> is called array. | ||
| 116 | |||
| 117 | An array consists of a set of L<numbers|/"Number">, a set of L<objects|/"Object">, or a set of L<multi-numeric numbers|/"Multi-Numeric Number">. | ||
| 118 | |||
| 119 | An array has its length. | ||
| 120 | |||
| 121 | The elements of an array are arranged by index and the index starts from 0. | ||
| 122 | |||
| 123 | An array is an L<object|/"Object">. | ||
| 124 | |||
| 125 | Normally, an array is created by L<new Operator|SPVM::Document::Language::Operators/"Creating an Array"> and an L<array initialization|SPVM::Document::Language::Operators/"Array Initialization">. | ||
| 126 | |||
| 127 | # An array created by new operator | ||
| 128 | my $numbers = new int[3]; | ||
| 129 | $numbergers->[0] = 1; | ||
| 130 | |||
| 131 | my $strings = new string[3]; | ||
| 132 | |||
| 133 | my $objects = new Point[3]; | ||
| 134 | |||
| 135 | my $mulnum_numbers = new Complex_2d[3]; | ||
| 136 | |||
| 137 | # An array created by an array initialization | ||
| 138 | my $numbers = [1, 2, 3]; | ||
| 139 | |||
| 140 | All elements of an array can be got by L<for statement|SPVM::Document::Language::Statements/"for Statement">. | ||
| 141 | |||
| 142 | # for statement | ||
| 143 | for (my $i = 0; $i < @$numbers; $i++) { | ||
| 144 | my $number = $numbers->[$i]; | ||
| 145 | } | ||
| 146 | |||
| 147 | # for-each statement | ||
| 148 | for my $number (@$numbers) { | ||
| 149 | |||
| 150 | } | ||
| 151 | |||
| 152 | See the following sections about operations for arrays. | ||
| 153 | |||
| 154 | =over 2 | ||
| 155 | |||
| 156 | =item * L<Creating Array in new Operator|SPVM::Document::Language::Operators/"Creating an Array"> | ||
| 157 | |||
| 158 | =item * L<Array Initialization|SPVM::Document::Language::Operators/"Array Initialization"> | ||
| 159 | |||
| 160 | =item * L<Array Length Operator|SPVM::Document::Language::Operators/"Array Length Operator"> | ||
| 161 | |||
| 162 | =item * L<Array Element Get Operation|SPVM::Document::Language::Operators/"Array Element Get Operation"> | ||
| 163 | |||
| 164 | =item * L<Array Element Set Operation|SPVM::Document::Language::Operators/"Array Element Set Operation"> | ||
| 165 | |||
| 166 | =back | ||
| 167 | |||
| 168 | =head2 Object | ||
| 169 | |||
| 170 | The value of an L<object type|/"Object Types"> is called object. | ||
| 171 | |||
| 172 | A L<string|/"String"> is an object. | ||
| 173 | |||
| 174 | An L<array|/"Array"> is an object. | ||
| 175 | |||
| 176 | An objcet of L<class type|/"Class Types"> has its fields. A field is a L<number|/"Number"> or an L<object|/"Object">. | ||
| 177 | |||
| 178 | Normally, an object is created by L<new|SPVM::Document::Language::Operators/"new"> operator. | ||
| 179 | |||
| 180 | # An object created by new operator | ||
| 181 | my $point = new Point; | ||
| 182 | |||
| 183 | When an object is created, memory for the object is allocated in heap memory. | ||
| 184 | |||
| 185 | Created objects are destroyed by L<garbage collection|SPVM::Document::Language::GarbageCollection>. | ||
| 186 | |||
| 187 | See the following sections about operations for objects. | ||
| 188 | |||
| 189 | =over 2 | ||
| 190 | |||
| 191 | =item * L<new Operator|SPVM::Document::Language::Operators/"new Operator"> | ||
| 192 | |||
| 193 | =item * L<dump Operator|SPVM::Document::Language::Operators/"dump Operator"> | ||
| 194 | |||
| 195 | =item * L<Field Get Operation|SPVM::Document::Language::Operators/"Field Get Operation"> | ||
| 196 | |||
| 197 | =item * L<Field Set Operation|SPVM::Document::Language::Operators/"Field Set Operation"> | ||
| 198 | |||
| 199 | =item * L<isa Operator|SPVM::Document::Language::Operators/"isa Operator"> | ||
| 200 | |||
| 201 | =item * L<is_type Operator|SPVM::Document::Language::Operators/"is_type Operator"> | ||
| 202 | |||
| 203 | =item * L<type_name Operator|SPVM::Document::Language::Operators/"type_name Operator"> | ||
| 204 | |||
| 205 | =back | ||
| 206 | |||
| 207 | =head3 Object Native Level Representation | ||
| 208 | |||
| 209 | At L<native level|SPVM::Document::NativeClass>, an object is a memory address. | ||
| 210 | |||
| 211 | void* obj_point = stack[0].oval; | ||
| 212 | |||
| 213 | =head2 Undefined Value | ||
| 214 | |||
| 215 | The value of L<undef type|/"undef Type"> is called undefined value. | ||
| 216 | |||
| 217 | An undefined value means the value is undefined. | ||
| 218 | |||
| 219 | An undefined value is created by L<undef|SPVM::Document::Language::Operators/"undef Operator"> operator. | ||
| 220 | |||
| 221 | undef | ||
| 222 | |||
| 223 | An undefined value is able to be assigned to an L<object type|/"Object Types">. | ||
| 224 | |||
| 225 | my $point : Point = undef; | ||
| 226 | |||
| 227 | Examples: | ||
| 228 | |||
| 229 | # Examples of undefined values | ||
| 230 | my $string : string = undef; | ||
| 231 | |||
| 232 | if (undef) { | ||
| 233 | |||
| 234 | } | ||
| 235 | |||
| 236 | my $message = "Hello"; | ||
| 237 | if ($message == undef) { | ||
| 238 | |||
| 239 | } | ||
| 240 | |||
| 241 | =head3 Undefined Value Native Level Representation | ||
| 242 | |||
| 243 | At L<native level|SPVM::Document::NativeClass>, an undefined value is equal to 0, normally a null pointer C<NULL> defined in C<stddef.h>. | ||
| 244 | |||
| 245 | NULL | ||
| 246 | |||
| 247 | =head2 Multi-Numeric Number | ||
| 248 | |||
| 249 | The value of a L<multi-numeric type|/"Multi-Numeric Types"> is called multi-numeric number. | ||
| 250 | |||
| 251 | A multi-numeric number is a set of L<numbers|/"Number"> of the same type. | ||
| 252 | |||
| 253 | my $z : Complex_2d; | ||
| 254 | $z->{re} = 1; | ||
| 255 | $z->{im} = 2; | ||
| 256 | |||
| 257 | See the following sections about operations for multi-numeric numbers. | ||
| 258 | |||
| 259 | =over 2 | ||
| 260 | |||
| 261 | =item * L<Multi-Numeric Field Get Operation|SPVM::Document::Language::Operators/"Multi-Numeric Field Get Operation"> | ||
| 262 | |||
| 263 | =item * L<Multi-Numeric Field Set Operation|SPVM::Document::Language::Operators/"Multi-Numeric Field Set Operation"> | ||
| 264 | |||
| 265 | =back | ||
| 266 | |||
| 267 | =head2 Reference | ||
| 268 | |||
| 269 | The value of a L<reference type|/"Reference Types"> is called reference. | ||
| 270 | |||
| 271 | A reference has a referencing value. | ||
| 272 | |||
| 273 | A referencing value must be a L<number|/"Number"> or a L<multi-numeric number|/"Multi-Numeric Number"> | ||
| 274 | |||
| 275 | The L<reference operator|SPVM::Document::Language::Operators/"Reference Operator"> C<\> creates a reference. | ||
| 276 | |||
| 277 | my $number : int; | ||
| 278 | my $number_ref = \$number; | ||
| 279 | |||
| 280 | See the following sections about operations for multi-numeric numbers. | ||
| 281 | |||
| 282 | =over 2 | ||
| 283 | |||
| 284 | =item * L<Referenced Value Get Operation|SPVM::Document::Language::Operators/"Referenced Value Get Operation"> | ||
| 285 | |||
| 286 | =item * L<Referenced Value Set Operation|SPVM::Document::Language::Operators/"Referenced Value Set Operation"> | ||
| 287 | |||
| 288 | =item * L<Reference Operator|SPVM::Document::Language::Operators/"Reference Operator"> | ||
| 289 | |||
| 290 | =item * L<Dereference Operator|SPVM::Document::Language::Operators/"Dereference Operator"> | ||
| 291 | |||
| 292 | =item * L<Referenced Multi-Numeric Field Get Operation|SPVM::Document::Language::Operators/"Referenced Multi-Numeric Field Get Operation"> | ||
| 293 | |||
| 294 | =item * L<Referenced Multi-Numeric Field Set Operation|SPVM::Document::Language::Operators/"Referenced Multi-Numeric Field Set Operation"> | ||
| 295 | |||
| 296 | =back | ||
| 297 | |||
| 298 | =head3 Reference Native Level Representation | ||
| 299 | |||
| 300 | At L<native level|SPVM::Document::NativeClass>, a reference is a memory address. | ||
| 301 | |||
| 302 | int32_t* num_ref = stack[0].iref; | ||
| 303 | |||
| 304 | =head1 Types | ||
| 305 | |||
| 306 | This section describes types. | ||
| 307 | |||
| 308 | =head2 Numeric Types | ||
| 309 | |||
| 310 | This section describes numeric types. | ||
| 311 | |||
| 312 | =head3 Integer Types | ||
| 313 | |||
| 314 | This section describes integer types. | ||
| 315 | |||
| 316 | An interger type is a L<numeric type|/"Numeric Types">. | ||
| 317 | |||
| 318 | =head4 byte Type | ||
| 319 | |||
| 320 | The C<byte> type is the type for a signed 8-bit integer. | ||
| 321 | |||
| 322 | byte | ||
| 323 | |||
| 324 | The C<byte> type is an L<integer type|/"Integer Types">. | ||
| 325 | |||
| 326 | =head4 short Type | ||
| 327 | |||
| 328 | The C<short> type is the type for a signed 16-bit integer. | ||
| 329 | |||
| 330 | short | ||
| 331 | |||
| 332 | The C<short> type is an L<integer type|/"Integer Types">. | ||
| 333 | |||
| 334 | =head4 int Type | ||
| 335 | |||
| 336 | The C<int> type is the type for a signed 32-bit integer. | ||
| 337 | |||
| 338 | int | ||
| 339 | |||
| 340 | The C<int> type is an L<integer type|/"Integer Types">. | ||
| 341 | |||
| 342 | =head4 long Type | ||
| 343 | |||
| 344 | The C<long> type is the type for a signed 64-bit integer. | ||
| 345 | |||
| 346 | long | ||
| 347 | |||
| 348 | The C<long> type is an L<integer type|/"Integer Types">. | ||
| 349 | |||
| 350 | =head3 Floating Point Types | ||
| 351 | |||
| 352 | This section describes floating point types. | ||
| 353 | |||
| 354 | A floating point type is a L<numeric type|/"Numeric Types">. | ||
| 355 | |||
| 356 | =head4 float Type | ||
| 357 | |||
| 358 | The C<float> type is the type for 32bit floating point. | ||
| 359 | |||
| 360 | float | ||
| 361 | |||
| 362 | The C<float> type is a L<floating point type|/"Floating Point Types">. | ||
| 363 | |||
| 364 | =head4 double Type | ||
| 365 | |||
| 366 | The C<double> type is the type for 64bit floating point. | ||
| 367 | |||
| 368 | double | ||
| 369 | |||
| 370 | The C<double> type is a L<floating point type|/"Floating Point Types">. | ||
| 371 | |||
| 372 | =head3 Numeric Types Order | ||
| 373 | |||
| 374 | L<numeric types|/"Numeric Types"> have its order. | ||
| 375 | |||
| 376 | The order is C<byte>, C<short>, C<int>, C<long>, C<float>, C<double> from smallest to largest. | ||
| 377 | |||
| 378 | =head2 Object Types | ||
| 379 | |||
| 380 | This section lists object types. | ||
| 381 | |||
| 382 | =head3 string Type | ||
| 383 | |||
| 384 | The C<string> type is the type for L<strings|/"String">. | ||
| 385 | |||
| 386 | string | ||
| 387 | |||
| 388 | The C<string> type is an L<object type|/"Object Types">. | ||
| 389 | |||
| 390 | The C<string> type can be qualified with L<mutable type qualifier|/"mutable Type Qualifier">. | ||
| 391 | |||
| 392 | mutable string | ||
| 393 | |||
| 394 | C<string> type has C<to_string> method and satisfies C<Stringable> interface. | ||
| 395 | |||
| 396 | The definition of C<to_string> method is as follows: | ||
| 397 | |||
| 398 | method to_string : string (); | ||
| 399 | |||
| 400 | This method returns itself. | ||
| 401 | |||
| 402 | Because C<string> type satisfies C<Stringable> interface, it can be cast or assigned to C<Stringable> interface. | ||
| 403 | |||
| 404 | Moreover, the array covariance is supported for C<string> type. For example, C<string[]> can be cast or assigned to C<Stringable[]>, and C<string[][]> can be cast or assigned to C<Stringable[][]>. | ||
| 405 | |||
| 406 | =head3 Class Types | ||
| 407 | |||
| 408 | A class type is the type for a L<class|SPVM::Document::Language::Class/"Class">. | ||
| 409 | |||
| 410 | A class type is defined by L<class definition|SPVM::Document::Language::Class/"Class Definition">. | ||
| 411 | |||
| 412 | class CLASS_TYPE { | ||
| 413 | |||
| 414 | } | ||
| 415 | |||
| 416 | An object can be created from a class by a L<new operator|SPVM::Document::Language::Operators/"new Operator">. | ||
| 417 | |||
| 418 | Note that an L<interface type|/"Interface Types"> and a L<multi-numeric type|/"Multi-Numeric Types"> is not a class type although these types are defined by L<class definition|SPVM::Document::Language::Class/"Class Definition">. | ||
| 419 | |||
| 420 | =head4 Numeric Object Types | ||
| 421 | |||
| 422 | A numeric object type is a L<class type|/"Class Types"> that owns the corresponding field of a L<numeric type|/"Numeric Types">. | ||
| 423 | |||
| 424 | The List of Numeric Object Types: | ||
| 425 | |||
| 426 | =begin html | ||
| 427 | |||
| 428 | <table> | ||
| 429 | <tr> | ||
| 430 | <th> | ||
| 431 | Numeric Object Types | ||
| 432 | </th> | ||
| 433 | <th> | ||
| 434 | Corresponding Numeric Types | ||
| 435 | </th> | ||
| 436 | </tr> | ||
| 437 | <tr> | ||
| 438 | <td> | ||
| 439 | <a href="https://metacpan.org/pod/SPVM::Byte">Byte</a> | ||
| 440 | </td> | ||
| 441 | <td> | ||
| 442 | byte | ||
| 443 | </td> | ||
| 444 | </tr> | ||
| 445 | <tr> | ||
| 446 | <td> | ||
| 447 | <a href="https://metacpan.org/pod/SPVM::Short">Short</a> | ||
| 448 | </td> | ||
| 449 | <td> | ||
| 450 | short | ||
| 451 | </td> | ||
| 452 | </tr> | ||
| 453 | <tr> | ||
| 454 | <td> | ||
| 455 | <a href="https://metacpan.org/pod/SPVM::Int">Int</a> | ||
| 456 | </td> | ||
| 457 | <td> | ||
| 458 | int | ||
| 459 | </td> | ||
| 460 | </tr> | ||
| 461 | <tr> | ||
| 462 | <td> | ||
| 463 | <a href="https://metacpan.org/pod/SPVM::Long">Long</a> | ||
| 464 | </td> | ||
| 465 | <td> | ||
| 466 | long | ||
| 467 | </td> | ||
| 468 | </tr> | ||
| 469 | <tr> | ||
| 470 | <td> | ||
| 471 | <a href="https://metacpan.org/pod/SPVM::Float">Float</a> | ||
| 472 | </td> | ||
| 473 | <td> | ||
| 474 | float | ||
| 475 | </td> | ||
| 476 | </tr> | ||
| 477 | <tr> | ||
| 478 | <td> | ||
| 479 | <a href="https://metacpan.org/pod/SPVM::Double">Double</a> | ||
| 480 | </td> | ||
| 481 | <td> | ||
| 482 | double | ||
| 483 | </td> | ||
| 484 | </tr> | ||
| 485 | </table> | ||
| 486 | |||
| 487 | =end html | ||
| 488 | |||
| 489 | =head3 Interface Types | ||
| 490 | |||
| 491 | An interface type is a type for an L<interface|SPVM::Document::Language::Class/"Interface">. | ||
| 492 | |||
| 493 | An interface type is defined by an L<interface definition|SPVM::Document::Language::Class/"Interface Definition">. | ||
| 494 | |||
| 495 | class INTERFACE_TYPE : interface_t { | ||
| 496 | |||
| 497 | } | ||
| 498 | |||
| 499 | =head3 Any Object Type | ||
| 500 | |||
| 501 | Any object type C<object> is the type to which any L<object type|/"Object Types"> can be assigned. | ||
| 502 | |||
| 503 | object | ||
| 504 | |||
| 505 | Examples: | ||
| 506 | |||
| 507 | # Examples of any object type | ||
| 508 | my $object: object = new Foo; | ||
| 509 | |||
| 510 | =head2 Basic Types | ||
| 511 | |||
| 512 | A basic type is a type whose type dimension is 0 and that can be an element of an array. | ||
| 513 | |||
| 514 | The List of Basic Types: | ||
| 515 | |||
| 516 | =over 2 | ||
| 517 | |||
| 518 | =item * L<Numeric types|/"Numeric Types"> | ||
| 519 | |||
| 520 | =item * L<Multi-numeric types|/"Multi-Numeric Types"> | ||
| 521 | |||
| 522 | =item * L<Class types|/"Class Types"> | ||
| 523 | |||
| 524 | =item * L<Interface types|/"Interface Types"> | ||
| 525 | |||
| 526 | =item * L<any object type|/"Any Object Type"> | ||
| 527 | |||
| 528 | =item * L<string type|/"string Type"> | ||
| 529 | |||
| 530 | =back | ||
| 531 | |||
| 532 | =head2 undef Type | ||
| 533 | |||
| 534 | The undef type is the type of an L<undefined value|/"Undefined Value">. | ||
| 535 | |||
| 536 | =head2 void Type | ||
| 537 | |||
| 538 | The C<void> type is the type that represents a method defined by a L<method definition|SPVM::Document::Language::Class/"Method Definition"> does not return a return value. | ||
| 539 | |||
| 540 | void | ||
| 541 | |||
| 542 | =head2 Array Types | ||
| 543 | |||
| 544 | An array type is a type for an L<array|/"Array">. An array type consists of a L<basic type|/"Basic Types"> and a type dimension such as C<[]>, C<[][]>. | ||
| 545 | |||
| 546 | BASIC_TYPE[].. | ||
| 547 | |||
| 548 | (C<[]..> means one more C<[]>) | ||
| 549 | |||
| 550 | Examples: | ||
| 551 | |||
| 552 | # Numeric array | ||
| 553 | int[] | ||
| 554 | double[] | ||
| 555 | |||
| 556 | # String array | ||
| 557 | string [] | ||
| 558 | |||
| 559 | # Class array | ||
| 560 | Point[] | ||
| 561 | |||
| 562 | # Any object array | ||
| 563 | object[] | ||
| 564 | |||
| 565 | # 2 dimensional array | ||
| 566 | int[][] | ||
| 567 | |||
| 568 | # 3 dimensional array | ||
| 569 | int[][][] | ||
| 570 | |||
| 571 | An array type is an L<object type|/"Object Types">. | ||
| 572 | |||
| 573 | Compilation Errors: | ||
| 574 | |||
| 575 | The dimesion is less than or equal to 255. Otherwise, a compilation error occurs. | ||
| 576 | |||
| 577 | =head3 Numeric Array Types | ||
| 578 | |||
| 579 | A numeric array type is an L<array type|/"Array Types"> of a L<numeric type|/"Numeric Types">. | ||
| 580 | |||
| 581 | The List of Numeric Array Types: | ||
| 582 | |||
| 583 | byte[] | ||
| 584 | short[] | ||
| 585 | int[] | ||
| 586 | long[] | ||
| 587 | float[] | ||
| 588 | double[] | ||
| 589 | |||
| 590 | =head3 Object Array Types | ||
| 591 | |||
| 592 | An object array type is an L<array type|/"Array Types"> of an L<object type|/"Object Types">. | ||
| 593 | |||
| 594 | Examples: | ||
| 595 | |||
| 596 | Point[] | ||
| 597 | Point[][] | ||
| 598 | Stringable[] | ||
| 599 | string[] | ||
| 600 | object[] | ||
| 601 | |||
| 602 | =head3 String Array Type | ||
| 603 | |||
| 604 | The string array type is L<array type|/"Array Types"> L<string type|/"string Type">. | ||
| 605 | |||
| 606 | string[] | ||
| 607 | |||
| 608 | =head3 Class Array Types | ||
| 609 | |||
| 610 | A class array type is an L<array type|/"Array Types"> of a L<class type|/"Class Types">. | ||
| 611 | |||
| 612 | Examples: | ||
| 613 | |||
| 614 | Int[] | ||
| 615 | Point[] | ||
| 616 | |||
| 617 | =head3 Interface Array Types | ||
| 618 | |||
| 619 | An interface array type is an L<array type|/"Array Types"> of an L<interface type|/"Interface Types">. | ||
| 620 | |||
| 621 | Examples: | ||
| 622 | |||
| 623 | Stringable[] | ||
| 624 | Cloneable[] | ||
| 625 | |||
| 626 | =head3 Multi-Dimensional Array Types | ||
| 627 | |||
| 628 | A multi-dimensional array type is an L<array type|/"Array Types"> of an L<array type|/"Array Types">. | ||
| 629 | |||
| 630 | Examples: | ||
| 631 | |||
| 632 | int[][] | ||
| 633 | Int[][] | ||
| 634 | string[][][] | ||
| 635 | object[][] | ||
| 636 | |||
| 637 | A multi-dimensional array is created by the syntax of L<creating a multi-dimensional array|SPVM::Document::Language::Operators/"Creating a Multi-Dimensional Array"> of the C<new> operator. | ||
| 638 | |||
| 639 | =head3 Multi-Numeric Array Types | ||
| 640 | |||
| 641 | A multi-numeric array type is an L<array type|/"Array Types"> of a L<multi-numeric type|"Multi-Numeric Types">. | ||
| 642 | |||
| 643 | Examples: | ||
| 644 | |||
| 645 | Complex_2d[] | ||
| 646 | Complex_2f[] | ||
| 647 | |||
| 648 | =head3 Any Object Array Type | ||
| 649 | |||
| 650 | The any object array type C<object[]> is L<array type|/"Array Types"> to which any L<object array type|/"Object Array Types"> can be assigned. | ||
| 651 | |||
| 652 | object[] | ||
| 653 | |||
| 654 | =head2 Multi-Numeric Types | ||
| 655 | |||
| 656 | A multi-numeric type is a type for a L<multi-numeric number|/"Multi-Numeric Number">. | ||
| 657 | |||
| 658 | A multi-numeric type is defined by a L<multi-numeric type definition|SPVM::Document::Language::Class/"Multi-Numeric Type Definition">. | ||
| 659 | |||
| 660 | class MULNUM_TYPE : mulnum_t { | ||
| 661 | |||
| 662 | } | ||
| 663 | |||
| 664 | =head2 Reference Types | ||
| 665 | |||
| 666 | A reference type is a type for a L<reference|/"Reference">. | ||
| 667 | |||
| 668 | TYPE* | ||
| 669 | |||
| 670 | A reference type consists of a type followed by C<*>. | ||
| 671 | |||
| 672 | I<TYPE> must be a L<numeric type|/"Numeric Types"> or a L<multi-numeric type|/"Multi-Numeric Types">. | ||
| 673 | |||
| 674 | =head3 Numeric Reference Types | ||
| 675 | |||
| 676 | A numeric reference type is a reference type of a L<numeric type|/"Numeric Types">. | ||
| 677 | |||
| 678 | The List of Numeric Reference Types: | ||
| 679 | |||
| 680 | byte* | ||
| 681 | short* | ||
| 682 | int* | ||
| 683 | long* | ||
| 684 | float* | ||
| 685 | double* | ||
| 686 | |||
| 687 | =head3 Multi-Numeric Reference Types | ||
| 688 | |||
| 689 | A multi-numeric reference types is a reference type of a L<multi-numeric type|/"Multi-Numeric Types">. | ||
| 690 | |||
| 691 | MULNUM_TYPE* | ||
| 692 | |||
| 693 | Examples: | ||
| 694 | |||
| 695 | Complex_2d* | ||
| 696 | Complex_2f* | ||
| 697 | |||
| 698 | =head2 Type Qualifiers | ||
| 699 | |||
| 700 | A type qualifier qualify a type. | ||
| 701 | |||
| 702 | QUALIFIER TYPE | ||
| 703 | |||
| 704 | The I<QUALIFIER> qualified the type I<TYPE>. | ||
| 705 | |||
| 706 | =head3 mutable Type Qualifier | ||
| 707 | |||
| 708 | The C<mutable> type qualifier qualifies string type. | ||
| 709 | |||
| 710 | mutable string; | ||
| 711 | |||
| 712 | The string of string type with the C<mutable> type qualifier is able to be L<set a character|SPVM::Document::Language::Operators/"Character Set Operation">. | ||
| 713 | |||
| 714 | my $string = (mutable string)copy "abc"; | ||
| 715 | $string->[0] = 'd'; | ||
| 716 | |||
| 717 | =head2 Type Initial Value | ||
| 718 | |||
| 719 | The value of a type is initialized by its type initial value. | ||
| 720 | |||
| 721 | The List of Type Initial Values: | ||
| 722 | |||
| 723 | =begin html | ||
| 724 | |||
| 725 | <table> | ||
| 726 | <tr> | ||
| 727 | <th> | ||
| 728 | <b>Types</b> | ||
| 729 | </th> | ||
| 730 | <th> | ||
| 731 | Type Initial Values | ||
| 732 | </th> | ||
| 733 | </tr> | ||
| 734 | <tr> | ||
| 735 | <td> | ||
| 736 | <b>byte</b> | ||
| 737 | </td> | ||
| 738 | <td> | ||
| 739 | 0 | ||
| 740 | </td> | ||
| 741 | </tr> | ||
| 742 | <tr> | ||
| 743 | <td> | ||
| 744 | <b>short</b> | ||
| 745 | </td> | ||
| 746 | <td> | ||
| 747 | 0 | ||
| 748 | </td> | ||
| 749 | </tr> | ||
| 750 | <tr> | ||
| 751 | <td> | ||
| 752 | <b>int</b> | ||
| 753 | </td> | ||
| 754 | <td> | ||
| 755 | 0 | ||
| 756 | </td> | ||
| 757 | </tr> | ||
| 758 | <tr> | ||
| 759 | <td> | ||
| 760 | <b>long</b> | ||
| 761 | </td> | ||
| 762 | <td> | ||
| 763 | 0 | ||
| 764 | </td> | ||
| 765 | </tr> | ||
| 766 | <tr> | ||
| 767 | <td> | ||
| 768 | <b>float</b> | ||
| 769 | </td> | ||
| 770 | <td> | ||
| 771 | 0 (All bits are 0) | ||
| 772 | </td> | ||
| 773 | </tr> | ||
| 774 | <tr> | ||
| 775 | <td> | ||
| 776 | <b>double</b> | ||
| 777 | </td> | ||
| 778 | <td> | ||
| 779 | 0 (All bits are 0) | ||
| 780 | </td> | ||
| 781 | </tr> | ||
| 782 | <tr> | ||
| 783 | <td> | ||
| 784 | <b><a href="#Object-Types">Object Types</a></b> | ||
| 785 | </td> | ||
| 786 | <td> | ||
| 787 | undef | ||
| 788 | </td> | ||
| 789 | </tr> | ||
| 790 | <tr> | ||
| 791 | <td> | ||
| 792 | <b><a href="#Multi-Numeric-Types">Multi-Numeric Types</a></b> | ||
| 793 | </td> | ||
| 794 | <td> | ||
| 795 | All fields are set to 0 (All bits are 0) | ||
| 796 | </td> | ||
| 797 | </tr> | ||
| 798 | </table> | ||
| 799 | |||
| 800 | =end html | ||
| 801 | |||
| 802 | =head2 Type Width | ||
| 803 | |||
| 804 | The type width is the length of L<runtime stack|SPVM::Document::NativeClass/"Runtime Stack"> of the type. | ||
| 805 | |||
| 806 | If the type is a L<multi-numeric type|/"Multi-Numeric Types">, the type width is the length of the fields, owhterwise it is 1. | ||
| 807 | |||
| 808 | =head2 Union Type | ||
| 809 | |||
| 810 | A union type expresses the logical OR of types. | ||
| 811 | |||
| 812 | TYPE1|TYPE2|TYPEn | ||
| 813 | |||
| 814 | A union type is treated as any object type C<object>. | ||
| 815 | |||
| 816 | Each element type in a union type must be an object type. | ||
| 817 | |||
| 818 | Compilation Errors: | ||
| 819 | |||
| 820 | If the type specified as the generic type is not found, a compilation error occurs. | ||
| 821 | |||
| 822 | If an element type is not an object type, a compilation error occurs. | ||
| 823 | |||
| 824 | Examples: | ||
| 825 | |||
| 826 | my $union = (string|string[])undef; | ||
| 827 | |||
| 828 | method : foo ($union : string|string[]) { | ||
| 829 | |||
| 830 | } | ||
| 831 | |||
| 832 | =head2 Generic Type | ||
| 833 | |||
| 834 | The generic type is | ||
| 835 | |||
| 836 | TYPE of ELEMENT_TYPE | ||
| 837 | |||
| 838 | I<TYPE> is a L<type|SPVM::Document::Language::Types/"Types">. | ||
| 839 | |||
| 840 | I<ELEMENT_TYPE> is a L<type|SPVM::Document::Language::Types/"Types">. | ||
| 841 | |||
| 842 | A generic type is treated as C<TYPE>. C<ELEMETN_TYPE> is ignored in compilation time type checks. | ||
| 843 | |||
| 844 | I<ELEMETN_TYPE> is only used for the type cast for C<element> type. | ||
| 845 | |||
| 846 | I<ELEMENT_TYPE> must be an object type. | ||
| 847 | |||
| 848 | Examples: | ||
| 849 | |||
| 850 | # Examples of generic types | ||
| 851 | has points : List of Point; | ||
| 852 | |||
| 853 | has hash_of_list_of_point : Hash of List of Point; | ||
| 854 | |||
| 855 | our $POINTS : List of Point; | ||
| 856 | |||
| 857 | my $points : List of Point; | ||
| 858 | |||
| 859 | static method foo : List of Point ($arg : List of Point) { ... } | ||
| 860 | |||
| 861 | my $replace : object of string|Regex::Replacer; | ||
| 862 | |||
| 863 | Compilation Errors: | ||
| 864 | |||
| 865 | If the type specified as the generic type is not found, a compilation error occurs. | ||
| 866 | |||
| 867 | If I<ELEMENT_TYPE> is not an object type, a compilation error occurs. | ||
| 868 | |||
| 869 | =head1 Assignment Requirement | ||
| 870 | |||
| 871 | The assignment requirement is the requirement whether one type is able to be assigned to another type. | ||
| 872 | |||
| 873 | What does it mean to assign one type to another type? | ||
| 874 | |||
| 875 | Typically, it is sufficient to consider a case where a value of a type I<TYPE_FROM> is assigned to a variable of a type I<TYPE_TO>. | ||
| 876 | |||
| 877 | my $value : TYPE_FROM; | ||
| 878 | my $var : TYPE_TO = $value; | ||
| 879 | |||
| 880 | Abstracting this, type-to-type assignment is defined. | ||
| 881 | |||
| 882 | TYPE_TO = TYPE_FROM | ||
| 883 | |||
| 884 | Note that this is a concept, not an actual syntax. | ||
| 885 | |||
| 886 | Some assinments perform a data conversion. | ||
| 887 | |||
| 888 | In the following description, the word "Type" is omitted when it is obvious. | ||
| 889 | |||
| 890 | =head2 Assignment Requirement to Numeric | ||
| 891 | |||
| 892 | =head3 Assignment Requirement from Numeric to Numeric | ||
| 893 | |||
| 894 | To Larger: | ||
| 895 | |||
| 896 | =begin html | ||
| 897 | |||
| 898 | <table> | ||
| 899 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 900 | <tr><td>Yes</td><td>byte</td><td>byte</td><td>No</td></tr> | ||
| 901 | <tr><td>Yes</td><td>short</td><td>short</td><td>No</td></tr> | ||
| 902 | <tr><td>Yes</td><td>int</td><td>int</td><td>No</td></tr> | ||
| 903 | <tr><td>Yes</td><td>long</td><td>long</td><td>No</td></tr> | ||
| 904 | <tr><td>Yes</td><td>float</td><td>float</td><td>No</td></tr> | ||
| 905 | <tr><td>Yes</td><td>double</td><td>double</td><td>No</td></tr> | ||
| 906 | <tr><td>Yes</td><td>short</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 907 | <tr><td>Yes</td><td>int</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 908 | <tr><td>Yes</td><td>long</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 909 | <tr><td>Yes</td><td>float</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 910 | <tr><td>Yes</td><td>double</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 911 | <tr><td>Yes</td><td>int</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 912 | <tr><td>Yes</td><td>long</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 913 | <tr><td>Yes</td><td>float</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 914 | <tr><td>Yes</td><td>double</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 915 | <tr><td>Yes</td><td>long</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 916 | <tr><td>Yes</td><td>float</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 917 | <tr><td>Yes</td><td>double</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 918 | <tr><td>Yes</td><td>float</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 919 | <tr><td>Yes</td><td>double</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 920 | <tr><td>Yes</td><td>double</td><td>float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td></tr> | ||
| 921 | </table> | ||
| 922 | |||
| 923 | =end html | ||
| 924 | |||
| 925 | To Smaller: | ||
| 926 | |||
| 927 | =begin html | ||
| 928 | |||
| 929 | <table> | ||
| 930 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 931 | <tr><td>Conditional Yes</td><td>byte</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></tr> | ||
| 932 | <tr><td>Conditional Yes</td><td>byte</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></tr> | ||
| 933 | <tr><td>Conditional Yes</td><td>byte</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></tr> | ||
| 934 | <tr><td>No</td><td>byte</td><td>float</td><td>No</td></tr> | ||
| 935 | <tr><td>No</td><td>byte</td><td>double</td><td>No</td></tr> | ||
| 936 | <tr><td>Conditional Yes</td><td>short</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></tr> | ||
| 937 | <tr><td>Conditional Yes</td><td>short</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></tr> | ||
| 938 | <tr><td>No</td><td>short</td><td>float</td><td>No</td></tr> | ||
| 939 | <tr><td>No</td><td>short</td><td>double</td><td>No</td></tr> | ||
| 940 | <tr><td>Conditional Yes</td><td>int</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></tr> | ||
| 941 | <tr><td>No</td><td>int</td><td>float</td><td>No</td></tr> | ||
| 942 | <tr><td>No</td><td>int</td><td>double</td><td>No</td></tr> | ||
| 943 | <tr><td>No</td><td>long</td><td>float</td><td>No</td></tr> | ||
| 944 | <tr><td>No</td><td>long</td><td>double</td><td>No</td></tr> | ||
| 945 | <tr><td>Conditional Yes</td><td>float</td><td>double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td></td></tr> | ||
| 946 | </table> | ||
| 947 | |||
| 948 | =end html | ||
| 949 | |||
| 950 | "Conditional Yes" means the followings. | ||
| 951 | |||
| 952 | For Integral Types: | ||
| 953 | |||
| 954 | If the value of I<TYPE_FROM> is represented by an L<interger literal|SPVM::Document::Language::Tokenization/"Integer Literals"> and between the max and minimal value of the type of I<TYPE_TO>, Yes, otherwize No. | ||
| 955 | |||
| 956 | For Floating Point types: | ||
| 957 | |||
| 958 | If the value of I<TYPE_FROM> is represented by a L<floating point literal|SPVM::Document::Language::Tokenization/"Floating Point Literals">, Yes, otherwize No. | ||
| 959 | |||
| 960 | =head3 Assignment Requirement from NumericObject to Numeric | ||
| 961 | |||
| 962 | =begin html | ||
| 963 | |||
| 964 | <table> | ||
| 965 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 966 | <tr><td>Yes</td><td>byte</td><td>Byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 967 | <tr><td>Yes</td><td>short</td><td>Short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 968 | <tr><td>Yes</td><td>int</td><td>Int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 969 | <tr><td>Yes</td><td>long</td><td>Long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 970 | <tr><td>Yes</td><td>float</td><td>Float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 971 | <tr><td>Yes</td><td>double</td><td>Double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 972 | </table> | ||
| 973 | |||
| 974 | =end html | ||
| 975 | |||
| 976 | =head3 Assignment Requirement from Any Object to Numeric | ||
| 977 | |||
| 978 | =begin html | ||
| 979 | |||
| 980 | <table> | ||
| 981 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 982 | <tr><td>Yes</td><td>byte</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 983 | <tr><td>Yes</td><td>short</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 984 | <tr><td>Yes</td><td>int</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 985 | <tr><td>Yes</td><td>long</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 986 | <tr><td>Yes</td><td>float</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 987 | <tr><td>Yes</td><td>double</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td></tr> | ||
| 988 | </table> | ||
| 989 | |||
| 990 | =end html | ||
| 991 | |||
| 992 | =head3 Assignment Requirement from Other to Numeric | ||
| 993 | |||
| 994 | =begin html | ||
| 995 | |||
| 996 | <table> | ||
| 997 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 998 | <tr><td>No</td><td>NumericX</td><td>Other</td><td>No</a></tr> | ||
| 999 | </table> | ||
| 1000 | |||
| 1001 | =end html | ||
| 1002 | |||
| 1003 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1004 | |||
| 1005 | =head2 Assignment Requirement to Multi-Numeric | ||
| 1006 | |||
| 1007 | =begin html | ||
| 1008 | |||
| 1009 | <table> | ||
| 1010 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1011 | <tr><td>Yes</td><td>Multi-NumericX</td><td>Multi-NumericX</td><td>No</td></tr> | ||
| 1012 | <tr><td>Yes</td><td>Multi-NumericX</td><td>undef</td><td>undef is converted to the initial value of a multi-numeric type where all fields are set to 0</td></tr> | ||
| 1013 | <tr><td>No</td><td>Multi-NumericX</td><td>Other</td><td>No</td></tr> | ||
| 1014 | </table> | ||
| 1015 | |||
| 1016 | =end html | ||
| 1017 | |||
| 1018 | I<Multi-NumericX> is a L<multi-numeric type|/"Multi-Numeric Types">. | ||
| 1019 | |||
| 1020 | =head2 Assignment Requirement to Referenece | ||
| 1021 | |||
| 1022 | =begin html | ||
| 1023 | |||
| 1024 | <table> | ||
| 1025 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1026 | <tr><td>Yes</td><td>ReferenceX</td><td>ReferenceX</td><td>No</td></tr> | ||
| 1027 | <tr><td>Yes</td><td>ReferenceX</td><td>undef</td><td>No</td></tr> | ||
| 1028 | <tr><td>No</td><td>ReferenceX</td><td>Other</td><td>No</td></tr> | ||
| 1029 | </table> | ||
| 1030 | |||
| 1031 | =end html | ||
| 1032 | |||
| 1033 | I<ReferenceX> is a L<reference type|/"Reference Types">. | ||
| 1034 | |||
| 1035 | =head2 Assignment Requirement to String | ||
| 1036 | |||
| 1037 | =begin html | ||
| 1038 | |||
| 1039 | <table> | ||
| 1040 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1041 | <tr><td>Yes</td><td>string</td><td>string</td><td>No</td></tr> | ||
| 1042 | <tr><td>Yes</td><td>string</td><td>mutable string</td><td>No</td></tr> | ||
| 1043 | <tr><td>Yes</td><td>mutable string</td><td>mutable string</td><td>No</td></tr> | ||
| 1044 | <tr><td>No</td><td>mutable string</td><td>string</td><td>No</td></tr> | ||
| 1045 | <tr><td>Yes</td><td>string</td><td>string</td><td>No</td></tr> | ||
| 1046 | <tr><td>Yes</td><td>string</td><td>NumericX</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-to-String-Conversion">Numeric-to-String Conversion</a></td></tr> | ||
| 1047 | <tr><td>Yes</td><td>string</td><td>undef</td><td>No</td></tr> | ||
| 1048 | <tr><td>No</td><td>string</td><td>Other</td><td>No</td></tr> | ||
| 1049 | </table> | ||
| 1050 | |||
| 1051 | =end html | ||
| 1052 | |||
| 1053 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1054 | |||
| 1055 | =head2 Assignment Requirement to NumericObject | ||
| 1056 | |||
| 1057 | =begin html | ||
| 1058 | |||
| 1059 | <table> | ||
| 1060 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1061 | <tr><td>Yes</td><td>NumericObjectX</td><td>NumericObjectX</td><td>No</td></tr> | ||
| 1062 | <tr><td>Yes</td><td>NumericObjectX</td><td>NumericX</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Boxing-Conversion">Boxing Conversion</a></td></tr> | ||
| 1063 | <tr><td>Yes</td><td>NumericObjectX</td><td>undef</td><td>No</td></tr> | ||
| 1064 | <tr><td>No</td><td>NumericObjectX</td><td>Other</td><td>No</td></tr> | ||
| 1065 | </table> | ||
| 1066 | |||
| 1067 | =end html | ||
| 1068 | |||
| 1069 | I<NumericObjectX> is a L<numeric object type|"Numeric Object Types">. | ||
| 1070 | |||
| 1071 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1072 | |||
| 1073 | =head2 Assignment Requirement to Class | ||
| 1074 | |||
| 1075 | =begin html | ||
| 1076 | |||
| 1077 | <table> | ||
| 1078 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1079 | <tr><td>Yes</td><td>ClassX</td><td>ClassX</td><td>No</td></tr> | ||
| 1080 | <tr><td>Yes</td><td>ClassX</td><td>undef</td><td>No</td></tr> | ||
| 1081 | <tr><td>Yes</td><td>SuperClassX</td><td>ClassX</td><td>No</td></tr> | ||
| 1082 | <tr><td>No</td><td>ClassX</td><td>Other</td><td>No</td></tr> | ||
| 1083 | </table> | ||
| 1084 | |||
| 1085 | =end html | ||
| 1086 | |||
| 1087 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1088 | |||
| 1089 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1090 | |||
| 1091 | =head2 Assignment Requirement to Interface | ||
| 1092 | |||
| 1093 | =begin html | ||
| 1094 | |||
| 1095 | <table> | ||
| 1096 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1097 | <tr><td>Yes</td><td>InterfaceX</td><td>InterfaceX</td><td>No</td></tr> | ||
| 1098 | <tr><td>Yes</td><td>InterfaceX</td><td>InterfaceSatisfiedX</td><td>No</td></tr> | ||
| 1099 | <tr><td>Yes</td><td>InterfaceX</td><td>undef</td><td>No</td></tr> | ||
| 1100 | <tr><td>No</td><td>InterfaceX</td><td>Other</td><td>No</td></tr> | ||
| 1101 | </table> | ||
| 1102 | |||
| 1103 | =end html | ||
| 1104 | |||
| 1105 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1106 | |||
| 1107 | I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>. | ||
| 1108 | |||
| 1109 | =head2 Assignment Requirement to Any Object | ||
| 1110 | |||
| 1111 | =begin html | ||
| 1112 | |||
| 1113 | <table> | ||
| 1114 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1115 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>ObjectX</td><td>No</td></tr> | ||
| 1116 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>NumericX</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Boxing-Conversion">Boxing Conversion</a></td></tr> | ||
| 1117 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>undef</td><td>No</td></tr> | ||
| 1118 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>void</td><td>No</td></tr> | ||
| 1119 | <tr><td>No</td><td>Any Object <code>object</code></td><td>Other</td><td>No</td></tr> | ||
| 1120 | </table> | ||
| 1121 | |||
| 1122 | =end html | ||
| 1123 | |||
| 1124 | I<ObjectX> is an L<object type|"Object Types">. | ||
| 1125 | |||
| 1126 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1127 | |||
| 1128 | =head2 Assignment Requirement to undef | ||
| 1129 | |||
| 1130 | =begin html | ||
| 1131 | |||
| 1132 | <table> | ||
| 1133 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1134 | <tr><td>No</td><td>undef</td><td>X</td><td>No</td></tr> | ||
| 1135 | </table> | ||
| 1136 | |||
| 1137 | =end html | ||
| 1138 | |||
| 1139 | I<X> is a type. | ||
| 1140 | |||
| 1141 | =head2 Assignment Requirement to void | ||
| 1142 | |||
| 1143 | =begin html | ||
| 1144 | |||
| 1145 | <table> | ||
| 1146 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1147 | <tr><td>Yes</td><td>void</td><td>void</td><td>No</td></tr> | ||
| 1148 | <tr><td>No</td><td>void</td><td>X</td><td>No</td></tr> | ||
| 1149 | </table> | ||
| 1150 | |||
| 1151 | =end html | ||
| 1152 | |||
| 1153 | I<X> is a type. | ||
| 1154 | |||
| 1155 | =head2 Assignment Requirement to Numeric Array | ||
| 1156 | |||
| 1157 | =begin html | ||
| 1158 | |||
| 1159 | <table> | ||
| 1160 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1161 | <tr><td>Yes</td><td>NumericX[]</td><td>NumericX[]</td><td>No</td></tr> | ||
| 1162 | <tr><td>Yes</td><td>NumericX[]</td><td>undef</td><td>No</td></tr> | ||
| 1163 | <tr><td>No</td><td>NumericX[]</td><td>Other</td><td>No</td></tr> | ||
| 1164 | </table> | ||
| 1165 | |||
| 1166 | =end html | ||
| 1167 | |||
| 1168 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1169 | |||
| 1170 | =head2 Assignment Requirement to Multi-Numeric Array | ||
| 1171 | |||
| 1172 | =begin html | ||
| 1173 | |||
| 1174 | <table> | ||
| 1175 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1176 | <tr><td>Yes</td><td>Multi-NumericX[]</td><td>Multi-NumericX[]</td><td>No</td></tr> | ||
| 1177 | <tr><td>Yes</td><td>Multi-NumericX[]</td><td>undef</td><td>No</td></tr> | ||
| 1178 | <tr><td>No</td><td>Multi-NumericX[]</td><td>Other</td><td>No</td></tr> | ||
| 1179 | </table> | ||
| 1180 | |||
| 1181 | =end html | ||
| 1182 | |||
| 1183 | I<Multi-NumericX> is a L<multi-numeric type|/"Multi-Numeric Types">. | ||
| 1184 | |||
| 1185 | =head2 Assignment Requirement to String Array | ||
| 1186 | |||
| 1187 | =begin html | ||
| 1188 | |||
| 1189 | <table> | ||
| 1190 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1191 | <tr><td>Yes</td><td>string[]</td><td>string[]</td><td>No</td></tr> | ||
| 1192 | <tr><td>Yes</td><td>string[]</td><td>undef</td><td>No</td></tr> | ||
| 1193 | <tr><td>No</td><td>string[]</td><td>Other</td><td>No</td></tr> | ||
| 1194 | </table> | ||
| 1195 | |||
| 1196 | =end html | ||
| 1197 | |||
| 1198 | =head2 Assignment Requirement to Class Array | ||
| 1199 | |||
| 1200 | =begin html | ||
| 1201 | |||
| 1202 | <table> | ||
| 1203 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1204 | <tr><td>Yes</td><td>ClassX[]</td><td>ClassX[]</td><td>No</td></tr> | ||
| 1205 | <tr><td>Yes</td><td>SuperClassX[]</td><td>ClassX[]</td><td>No</td></tr> | ||
| 1206 | <tr><td>Yes</td><td>ClassX[]</td><td>undef</td><td>No</td></tr> | ||
| 1207 | <tr><td>No</td><td>ClassX[]</td><td>Other</td><td>No</td></tr> | ||
| 1208 | </table> | ||
| 1209 | |||
| 1210 | =end html | ||
| 1211 | |||
| 1212 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1213 | |||
| 1214 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1215 | |||
| 1216 | =head2 Assignment Requirement to Interface Array | ||
| 1217 | |||
| 1218 | =begin html | ||
| 1219 | |||
| 1220 | <table> | ||
| 1221 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1222 | <tr><td>Yes</td><td>InterfaceX[]</td><td>InterfaceX[]</td><td>No</td></tr> | ||
| 1223 | <tr><td>Yes</td><td>InterfaceX[]</td><td>InterfaceSatisfiedX[]</td><td>No</td></tr> | ||
| 1224 | <tr><td>Yes</td><td>InterfaceX[]</td><td>undef</td><td>No</td></tr> | ||
| 1225 | <tr><td>No</td><td>InterfaceX[]</td><td>Other</td><td>No</td></tr> | ||
| 1226 | </table> | ||
| 1227 | |||
| 1228 | =end html | ||
| 1229 | |||
| 1230 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1231 | |||
| 1232 | I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>. | ||
| 1233 | |||
| 1234 | =head2 Assignment Requirement to Any Object Array | ||
| 1235 | |||
| 1236 | =begin html | ||
| 1237 | |||
| 1238 | <table> | ||
| 1239 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1240 | <tr><td>Yes</td><td>Any Object Array <code>object[]</code></td><td>ObjectX[]..</td><td>No</td></tr> | ||
| 1241 | <tr><td>Yes</td><td>Any Object Array <code>object[]</code></td><td>undef</td><td>No</td></tr> | ||
| 1242 | <tr><td>No</td><td>Any Object Array <code>object[]</code></td><td>Other</td><td>No</td></tr> | ||
| 1243 | </table> | ||
| 1244 | |||
| 1245 | =end html | ||
| 1246 | |||
| 1247 | I<ObjectX> is an L<object type|"Object Types">. | ||
| 1248 | |||
| 1249 | C<[]..> is one or more C<[]>. | ||
| 1250 | |||
| 1251 | =head2 Assignment Requirement to Multi-Dimensional Array | ||
| 1252 | |||
| 1253 | =begin html | ||
| 1254 | |||
| 1255 | <table> | ||
| 1256 | <tr><th>Assignment Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th></tr> | ||
| 1257 | <tr><td>Yes</td><td>X[]..D</td><td>X[]..D</td><td>No</td></tr> | ||
| 1258 | <tr><td>Yes</td><td>X[]..D</td><td>undef</td><td>No</td></tr> | ||
| 1259 | <tr><td>Yes</td><td>SuperClassX[]..D</td><td>ClassX[]..D</td><td>No</td></tr> | ||
| 1260 | <tr><td>Yes</td><td>InterfaceX[]..D</td><td>InterfaceSatisfiedX[]..D</td><td>No</td></tr> | ||
| 1261 | <tr><td>No</td><td>X[]..D</td><td>Other</td><td>No</td></tr> | ||
| 1262 | </table> | ||
| 1263 | |||
| 1264 | =end html | ||
| 1265 | |||
| 1266 | I<X> is a type. | ||
| 1267 | |||
| 1268 | C<[]..> is one or more C<[]>. | ||
| 1269 | |||
| 1270 | I<D> means its type dimension that is greater than or eausl to 2. | ||
| 1271 | |||
| 1272 | I<X[]..D> is a multi-dimensional array. | ||
| 1273 | |||
| 1274 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1275 | |||
| 1276 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1277 | |||
| 1278 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1279 | |||
| 1280 | I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>. | ||
| 1281 | |||
| 1282 | =head1 Cast Requirement | ||
| 1283 | |||
| 1284 | The cast requirement is the requirement whether one type is able to be cast to another type. | ||
| 1285 | |||
| 1286 | What does it mean to cast one type to another type? | ||
| 1287 | |||
| 1288 | Typically, it is sufficient to consider a case where a value of a type I<TYPE_FROM> is casted to I<TYPE_TO>. | ||
| 1289 | |||
| 1290 | my $value : TYPE_FROM; | ||
| 1291 | (TYPE_TO)$value; | ||
| 1292 | |||
| 1293 | Abstracting this, type-to-type cast is defined. | ||
| 1294 | |||
| 1295 | (TYPE_TO)TYPE_FROM | ||
| 1296 | |||
| 1297 | Note that this is a concept, not an actual syntax. | ||
| 1298 | |||
| 1299 | Some type casts perform a data conversion. | ||
| 1300 | |||
| 1301 | Some type casts perform a data check. | ||
| 1302 | |||
| 1303 | In the following description, the word "Type" is omitted when it is obvious. | ||
| 1304 | |||
| 1305 | =head2 Cast Requirement to Numeric | ||
| 1306 | |||
| 1307 | =head3 Cast Requirement from Numeric to Numeric | ||
| 1308 | |||
| 1309 | To Larger: | ||
| 1310 | |||
| 1311 | =begin html | ||
| 1312 | |||
| 1313 | <table> | ||
| 1314 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1315 | <tr><td>Yes</td><td>byte</td><td>byte</td><td>No</td><td>No</td></tr> | ||
| 1316 | <tr><td>Yes</td><td>short</td><td>short</td><td>No</td><td>No</td></tr> | ||
| 1317 | <tr><td>Yes</td><td>int</td><td>int</td><td>No</td><td>No</td></tr> | ||
| 1318 | <tr><td>Yes</td><td>long</td><td>long</td><td>No</td><td>No</td></tr> | ||
| 1319 | <tr><td>Yes</td><td>float</td><td>float</td><td>No</td><td>No</td></tr> | ||
| 1320 | <tr><td>Yes</td><td>double</td><td>double</td><td>No</td><td>No</td></tr> | ||
| 1321 | <tr><td>Yes</td><td>short</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1322 | <tr><td>Yes</td><td>int</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1323 | <tr><td>Yes</td><td>long</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1324 | <tr><td>Yes</td><td>float</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1325 | <tr><td>Yes</td><td>double</td><td>byte</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1326 | <tr><td>Yes</td><td>int</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1327 | <tr><td>Yes</td><td>long</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1328 | <tr><td>Yes</td><td>float</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1329 | <tr><td>Yes</td><td>double</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1330 | <tr><td>Yes</td><td>long</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1331 | <tr><td>Yes</td><td>float</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1332 | <tr><td>Yes</td><td>double</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1333 | <tr><td>Yes</td><td>float</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1334 | <tr><td>Yes</td><td>double</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1335 | <tr><td>Yes</td><td>double</td><td>float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Widening-Conversion">Numeric Widening Conversion</a></td><td>No</td></tr> | ||
| 1336 | </table> | ||
| 1337 | |||
| 1338 | =end html | ||
| 1339 | |||
| 1340 | To Smaller: | ||
| 1341 | |||
| 1342 | =begin html | ||
| 1343 | |||
| 1344 | <table> | ||
| 1345 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1346 | <tr><td>Yes</td><td>byte</td><td>short</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1347 | <tr><td>Yes</td><td>byte</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1348 | <tr><td>Yes</td><td>byte</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1349 | <tr><td>Yes</td><td>byte</td><td>float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1350 | <tr><td>Yes</td><td>byte</td><td>double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1351 | <tr><td>Yes</td><td>short</td><td>int</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1352 | <tr><td>Yes</td><td>short</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1353 | <tr><td>Yes</td><td>short</td><td>float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1354 | <tr><td>Yes</td><td>short</td><td>double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1355 | <tr><td>Yes</td><td>int</td><td>long</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1356 | <tr><td>Yes</td><td>int</td><td>float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1357 | <tr><td>Yes</td><td>int</td><td>double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1358 | <tr><td>Yes</td><td>long</td><td>float</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1359 | <tr><td>Yes</td><td>long</td><td>double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1360 | <tr><td>Yes</td><td>float</td><td>double</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-Narrowing-Conversion">Numeric Narrowing Conversion</a></td><td>No</td></tr> | ||
| 1361 | </table> | ||
| 1362 | |||
| 1363 | =end html | ||
| 1364 | |||
| 1365 | =head3 Cast Requirement from NumericObject to Numeric | ||
| 1366 | |||
| 1367 | =begin html | ||
| 1368 | |||
| 1369 | <table> | ||
| 1370 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1371 | <tr><td>Yes</td><td>byte</td><td>Numeric Object</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1372 | <tr><td>Yes</td><td>short</td><td>Numeric Object</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1373 | <tr><td>Yes</td><td>int</td><td>Numeric Object</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1374 | <tr><td>Yes</td><td>long</td><td>Numeric Object</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1375 | <tr><td>Yes</td><td>float</td><td>Numeric Object</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1376 | <tr><td>Yes</td><td>double</td><td>Numeric Object</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1377 | </table> | ||
| 1378 | |||
| 1379 | =end html | ||
| 1380 | |||
| 1381 | =head3 Cast Requirement from Any Object to Numeric | ||
| 1382 | |||
| 1383 | =begin html | ||
| 1384 | |||
| 1385 | <table> | ||
| 1386 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1387 | <tr><td>Yes</td><td>NumericX</td><td>Any Object <code>object</code></td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Unboxing-Conversion">Unboxing Conversion</a></td><td>No</td></tr> | ||
| 1388 | </table> | ||
| 1389 | |||
| 1390 | =end html | ||
| 1391 | |||
| 1392 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1393 | |||
| 1394 | =head3 Cast Requirement from Other to Numeric | ||
| 1395 | |||
| 1396 | =begin html | ||
| 1397 | |||
| 1398 | <table> | ||
| 1399 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1400 | <tr><td>No</td><td>NumericX</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1401 | </table> | ||
| 1402 | |||
| 1403 | =end html | ||
| 1404 | |||
| 1405 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1406 | |||
| 1407 | =head2 Cast Requirement to Multi-Numeric | ||
| 1408 | |||
| 1409 | =begin html | ||
| 1410 | |||
| 1411 | <table> | ||
| 1412 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1413 | <tr><td>Yes</td><td>Multi-NumericX</td><td>Multi-NumericX</td><td>No</td><td>No</td></tr> | ||
| 1414 | <tr><td>Yes</td><td>Multi-NumericX</td><td>undef</td><td>No</td><td>undef is converted to the initial value of a multi-numeric type where all fields are set to 0</td></tr> | ||
| 1415 | <tr><td>No</td><td>Multi-NumericX</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1416 | </table> | ||
| 1417 | |||
| 1418 | =end html | ||
| 1419 | |||
| 1420 | I<Multi-NumericX> is a L<multi-numeric type|/"Multi-Numeric Types">. | ||
| 1421 | |||
| 1422 | =head2 Cast Requirement to Referenece | ||
| 1423 | |||
| 1424 | =begin html | ||
| 1425 | |||
| 1426 | <table> | ||
| 1427 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1428 | <tr><td>Yes</td><td>ReferenceX</td><td>ReferenceX</td><td>No</td><td>No</td></tr> | ||
| 1429 | <tr><td>Yes</td><td>ReferenceX</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1430 | <tr><td>No</td><td>ReferenceX</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1431 | </table> | ||
| 1432 | |||
| 1433 | =end html | ||
| 1434 | |||
| 1435 | I<ReferenceX> is a L<reference type|/"Reference Types">. | ||
| 1436 | |||
| 1437 | =head2 Cast Requirement to String | ||
| 1438 | |||
| 1439 | =begin html | ||
| 1440 | |||
| 1441 | <table> | ||
| 1442 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1443 | <tr><td>Yes</td><td>string</td><td>string</td><td>No</td><td>No</td></tr> | ||
| 1444 | <tr><td>Yes</td><td>string</td><td>mutable string</td><td>No</td><td>No</td></tr> | ||
| 1445 | <tr><td>Yes</td><td>mutable string</td><td>mutable string</td><td>No</td><td>No</td></tr> | ||
| 1446 | <tr><td>Yes</td><td>mutable string</td><td>string</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#is_read_only-Operator">is_read_only Operator</a></td></tr> | ||
| 1447 | <tr><td>Yes</td><td>string</td><td>string</td><td>No</td><td>No</td></tr> | ||
| 1448 | <tr><td>Yes</td><td>string</td><td>NumericX</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Numeric-to-String-Conversion">Numeric-to-String Conversion</a></td><td>No</td></tr> | ||
| 1449 | <tr><td>Yes</td><td>string</td><td>Numeric Object X<code>object</code></td><td>Yes</td><td>See below *1</td></tr> | ||
| 1450 | <tr><td>Yes</td><td>string</td><td>Any Object <code>object</code></td><td>Yes</td><td>See below *1</td></tr> | ||
| 1451 | <tr><td>Yes</td><td>string</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1452 | <tr><td>No</td><td>string</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1453 | </table> | ||
| 1454 | |||
| 1455 | *1 | ||
| 1456 | |||
| 1457 | If the object is undef, it is returned. | ||
| 1458 | |||
| 1459 | If the cast type is C<mutable string>, and the object is read-only, throws an exception. | ||
| 1460 | |||
| 1461 | If the object is a numeric object, the value is converted to a numeric value using L<SPVM::Document::Language::Operators#/"Numeric-to-String Conversion">. | ||
| 1462 | |||
| 1463 | If the object is string type, it is returned. | ||
| 1464 | |||
| 1465 | If the object is other type, an exception is thrown. | ||
| 1466 | |||
| 1467 | =end html | ||
| 1468 | |||
| 1469 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1470 | |||
| 1471 | =head2 Cast Requirement to NumericObject | ||
| 1472 | |||
| 1473 | =begin html | ||
| 1474 | |||
| 1475 | <table> | ||
| 1476 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1477 | <tr><td>Yes</td><td>NumericObjectX</td><td>NumericObjectX</td><td>No</td><td>No</td></tr> | ||
| 1478 | <tr><td>Yes</td><td>NumericObjectX</td><td>NumericX</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Boxing-Conversion">Boxing Conversion</a></td><td>No</td></tr> | ||
| 1479 | <tr><td>Yes</td><td>NumericObjectX</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1480 | <tr><td>Yes</td><td>NumericObjectX</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1481 | <tr><td>No</td><td>NumericObjectX</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1482 | </table> | ||
| 1483 | |||
| 1484 | =end html | ||
| 1485 | |||
| 1486 | I<NumericObjectX> is a L<numeric object type|"Numeric Object Types">. | ||
| 1487 | |||
| 1488 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1489 | |||
| 1490 | =head2 Cast Requirement to Class | ||
| 1491 | |||
| 1492 | =begin html | ||
| 1493 | |||
| 1494 | <table> | ||
| 1495 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1496 | <tr><td>Yes</td><td>ClassX</td><td>ClassX</td><td>No</td><td>No</td></tr> | ||
| 1497 | <tr><td>Yes</td><td>SuperClassX</td><td>ClassX</td><td>No</td><td>No</td></tr> | ||
| 1498 | <tr><td>Yes</td><td>ClassX</td><td>SuperClassX</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1499 | <tr><td>Yes</td><td>ClassX</td><td>InterfaceX</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1500 | <tr><td>Yes</td><td>ClassX</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1501 | <tr><td>Yes</td><td>ClassX</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1502 | <tr><td>No</td><td>ClassX</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1503 | </table> | ||
| 1504 | |||
| 1505 | =end html | ||
| 1506 | |||
| 1507 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1508 | |||
| 1509 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1510 | |||
| 1511 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1512 | |||
| 1513 | =head2 Cast Requirement to Interface | ||
| 1514 | |||
| 1515 | =begin html | ||
| 1516 | |||
| 1517 | <table> | ||
| 1518 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1519 | <tr><td>Yes</td><td>InterfaceX</td><td>InterfaceX</td><td>No</td><td>No</td></tr> | ||
| 1520 | <tr><td>Yes</td><td>InterfaceX</td><td>InterfaceSatisfiedX</td><td>No</td><td>No</td></tr> | ||
| 1521 | <tr><td>Yes</td><td>InterfaceX</td><td>InterfaceY</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1522 | <tr><td>Yes</td><td>InterfaceX</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1523 | <tr><td>Yes</td><td>InterfaceX</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1524 | <tr><td>No</td><td>InterfaceX</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1525 | </table> | ||
| 1526 | |||
| 1527 | =end html | ||
| 1528 | |||
| 1529 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1530 | |||
| 1531 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1532 | |||
| 1533 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1534 | |||
| 1535 | I<InterfaceY> is a an L<interface type|"Interface Types">. | ||
| 1536 | |||
| 1537 | I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>. | ||
| 1538 | |||
| 1539 | =head2 Cast Requirement to Any Object | ||
| 1540 | |||
| 1541 | =begin html | ||
| 1542 | |||
| 1543 | <table> | ||
| 1544 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1545 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>ObjectX</td><td>No</td><td>No</td></tr> | ||
| 1546 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>NumericX</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#Boxing-Conversion">Boxing Conversion</a></td><td>No</td></tr> | ||
| 1547 | <tr><td>Yes</td><td>Any Object <code>object</code></td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1548 | <tr><td>No</td><td>Any Object <code>object</code></td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1549 | </table> | ||
| 1550 | |||
| 1551 | =end html | ||
| 1552 | |||
| 1553 | I<ObjectX> is an L<object type|"Object Types">. | ||
| 1554 | |||
| 1555 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1556 | |||
| 1557 | =head2 Cast Requirement to Numeric Array | ||
| 1558 | |||
| 1559 | =begin html | ||
| 1560 | |||
| 1561 | <table> | ||
| 1562 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1563 | <tr><td>Yes</td><td>byte[]</td><td>string</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#String-to-byte[]-Conversion">String-to-byte[] Conversion</a></td><td>No</td></tr> | ||
| 1564 | <tr><td>Yes</td><td>NumericX[]</td><td>NumericX[]</td><td>No</td><td>No</td></tr> | ||
| 1565 | <tr><td>Yes</td><td>NumericX[]</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1566 | <tr><td>Yes</td><td>NumericX[]</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1567 | <tr><td>No</td><td>NumericX[]</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1568 | </table> | ||
| 1569 | |||
| 1570 | =end html | ||
| 1571 | |||
| 1572 | I<NumericX> is a L<numeric type|"Numeric Types">. | ||
| 1573 | |||
| 1574 | =head2 Cast Requirement to Multi-Numeric Array | ||
| 1575 | |||
| 1576 | =begin html | ||
| 1577 | |||
| 1578 | <table> | ||
| 1579 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1580 | <tr><td>Yes</td><td>Multi-NumericX[]</td><td>Multi-NumericX[]</td><td>No</td><td>No</td></tr> | ||
| 1581 | <tr><td>Yes</td><td>Multi-NumericX[]</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1582 | <tr><td>Yes</td><td>Multi-NumericX[]</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1583 | <tr><td>No</td><td>Multi-NumericX[]</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1584 | </table> | ||
| 1585 | |||
| 1586 | =end html | ||
| 1587 | |||
| 1588 | I<Multi-NumericX> is a L<multi-numeric type|/"Multi-Numeric Types">. | ||
| 1589 | |||
| 1590 | =head2 Cast Requirement to String Array | ||
| 1591 | |||
| 1592 | =begin html | ||
| 1593 | |||
| 1594 | <table> | ||
| 1595 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1596 | <tr><td>Yes</td><td>string[]</td><td>string[]</td><td>No</td><td>No</td></tr> | ||
| 1597 | <tr><td>Yes</td><td>string[]</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1598 | <tr><td>Yes</td><td>string[]</td><td>Any Object Array <code>object[]</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1599 | <tr><td>Yes</td><td>string[]</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1600 | <tr><td>No</td><td>string[]</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1601 | </table> | ||
| 1602 | |||
| 1603 | =end html | ||
| 1604 | |||
| 1605 | =head2 Cast Requirement to Class Array | ||
| 1606 | |||
| 1607 | =begin html | ||
| 1608 | |||
| 1609 | <table> | ||
| 1610 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1611 | <tr><td>Yes</td><td>ClassX[]</td><td>ClassX[]</td><td>No</td><td>No</td></tr> | ||
| 1612 | <tr><td>Yes</td><td>SuperClassX[]</td><td>ClassX[]</td><td>No</td><td>No</td></tr> | ||
| 1613 | <tr><td>Yes</td><td>ClassX[]</td><td>SuperClassX[]</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1614 | <tr><td>Yes</td><td>ClassX[]</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1615 | <tr><td>Yes</td><td>ClassX[]</td><td>Any Object Array <code>object[]</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1616 | <tr><td>Yes</td><td>ClassX[]</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1617 | <tr><td>No</td><td>ClassX[]</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1618 | </table> | ||
| 1619 | |||
| 1620 | =end html | ||
| 1621 | |||
| 1622 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1623 | |||
| 1624 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1625 | |||
| 1626 | =head2 Cast Requirement to Interface Array | ||
| 1627 | |||
| 1628 | =begin html | ||
| 1629 | |||
| 1630 | <table> | ||
| 1631 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1632 | <tr><td>Yes</td><td>InterfaceX[]</td><td>InterfaceX[]</td><td>No</td><td>No</td></tr> | ||
| 1633 | <tr><td>Yes</td><td>InterfaceX[]</td><td>InterfaceSatisfiedX[]</td><td>No</td><td>No</td></tr> | ||
| 1634 | <tr><td>Yes</td><td>InterfaceX[]</td><td>InterfaceY[]</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1635 | <tr><td>Yes</td><td>InterfaceX[]</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1636 | <tr><td>Yes</td><td>InterfaceX[]</td><td>Any Object Array <code>object[]</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1637 | <tr><td>Yes</td><td>InterfaceX[]</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1638 | <tr><td>No</td><td>InterfaceX[]</td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1639 | </table> | ||
| 1640 | |||
| 1641 | =end html | ||
| 1642 | |||
| 1643 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1644 | |||
| 1645 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1646 | |||
| 1647 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1648 | |||
| 1649 | I<InterfaceY> is a an L<interface type|"Interface Types">. | ||
| 1650 | |||
| 1651 | I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>. | ||
| 1652 | |||
| 1653 | =head2 Cast Requirement to Any Object Array | ||
| 1654 | |||
| 1655 | =begin html | ||
| 1656 | |||
| 1657 | <table> | ||
| 1658 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1659 | <tr><td>Yes</td><td>Any Object Array <code>object[]</code></td><td>ObjectX[]..</td><td>No</td><td>No</td></tr> | ||
| 1660 | <tr><td>Yes</td><td>Any Object Array <code>object[]</code></td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1661 | <tr><td>Yes</td><td>Any Object Array <code>object[]</code></td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1662 | <tr><td>No</td><td>Any Object Array <code>object[]</code></td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1663 | </table> | ||
| 1664 | |||
| 1665 | =end html | ||
| 1666 | |||
| 1667 | I<ObjectX> is an L<object type|"Object Types">. | ||
| 1668 | |||
| 1669 | C<[]..> is one or more C<[]>. | ||
| 1670 | |||
| 1671 | =head2 Cast Requirement to Multi-Dimensional Array | ||
| 1672 | |||
| 1673 | =begin html | ||
| 1674 | |||
| 1675 | <table> | ||
| 1676 | <tr><th>Cast Requirement<br>Satisfaction</th><th>To</th><th>From</th><th>Data Conversion</th><th>Data Check</th></tr> | ||
| 1677 | <tr><td>Yes</td><td>X[]..D</td><td>X[]..D</td><td>No</td><td>No</td></tr> | ||
| 1678 | <tr><td>Yes</td><td>X[]..D</td><td>Any Object <code>object</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1679 | <tr><td>Yes</td><td>X[]..D</td><td>Any Object Array <code>object[]</code></td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1680 | <tr><td>Yes</td><td>X[]..D</td><td>undef</td><td>No</td><td>No</td></tr> | ||
| 1681 | <tr><td>Yes</td><td>SuperClassX[]..</td><td>ClassX[]..D</td><td>No</td><td>No</td></tr> | ||
| 1682 | <tr><td>Yes</td><td>ClassX[]..</td><td>SuperClassX[]..D</td><td>No</td><td><a href="https://metacpan.org/pod/SPVM::Document::Language::Operators#isa-Operator">isa Operator</a></td></tr> | ||
| 1683 | <tr><td>Yes</td><td>InterfaceX[]..D</td><td>InterfaceSatisfiedX[]..D</td><td>No</td><td>No</td></tr> | ||
| 1684 | <tr><td>No</td><td>Any Object Array <code>object[]</code></td><td>Other</td><td>No</td><td>No</td></tr> | ||
| 1685 | </table> | ||
| 1686 | |||
| 1687 | =end html | ||
| 1688 | |||
| 1689 | I<X> is a type. | ||
| 1690 | |||
| 1691 | C<[]..> is one or more C<[]>. | ||
| 1692 | |||
| 1693 | I<D> means its type dimension that is greater than or eausl to 2. | ||
| 1694 | |||
| 1695 | I<X[]..D> is a multi-dimensional array. | ||
| 1696 | |||
| 1697 | I<ClassX> is a L<class type|"Class Types">. | ||
| 1698 | |||
| 1699 | I<SuperClassX> is a super class of I<ClassX>. | ||
| 1700 | |||
| 1701 | I<InterfaceX> is a an L<interface type|"Interface Types">. | ||
| 1702 | |||
| 1703 | I<InterfaceSatisfiedX> is a L<class type|"Class Types"> or an L<interface type|"Interface Types"> that satisfied L<interface requirement|/"Interface Requirement"> of I<InterfaceX>. | ||
| 1704 | |||
| 1705 | =head1 Interface Requirement | ||
| 1706 | |||
| 1707 | The interface requirement is the requirement whether an L<object type|"Object Types"> is able to be assigned to an L<interface type|"Interface Types">. | ||
| 1708 | |||
| 1709 | INTERFACE_TYPE_TO = OBJECT_TYPE_FROM | ||
| 1710 | |||
| 1711 | This is the same concept as type-to-type assignment explained in L<Assignment Requirement|/"Assignment Requirement">. | ||
| 1712 | |||
| 1713 | I<INTERFACE_TYPE_TO> must be an L<interface type|"Interface Types">. | ||
| 1714 | |||
| 1715 | I<OBJECT_TYPE_FROM> must be a L<class type|"Class Types"> or an L<interface type|"Interface Types">. | ||
| 1716 | |||
| 1717 | The following check is performed on every instance method of I<OBJECT_TYPE_FROM>. | ||
| 1718 | |||
| 1719 | If an instance method of I<INTERFACE_TYPE_TO> has the C<required> method attribute, I<OBJECT_TYPE_FROM> or one of its super classes must have a method with the same name. | ||
| 1720 | |||
| 1721 | If I<OBJECT_TYPE_FROM> or one of its super classes has an instance method(this is named I<METHOD_FROM>) with the same name as an instance method of I<INTERFACE_TYPE_TO>, | ||
| 1722 | I<METHOD_FROM> must be an instance method and satisfy L<interface method requirement|/"Interface Method Requirement">. | ||
| 1723 | |||
| 1724 | =head2 Interface Method Requirement | ||
| 1725 | |||
| 1726 | The interface method requirement is the requirement whether a method is able to be assigned to an interface method. | ||
| 1727 | |||
| 1728 | INTERFACE_METHOD_TO = METHOD_FROM | ||
| 1729 | |||
| 1730 | This is a concept that converts the type-to-type assignment explained in L<Assignment Requirement|/"Assignment Requirement"> to method-to-method assignment. | ||
| 1731 | |||
| 1732 | I<INTERFACE_METHOD_TO> must be an instance method. | ||
| 1733 | |||
| 1734 | I<METHOD_FROM> must be an instance method. | ||
| 1735 | |||
| 1736 | The length of the arguments of the method of the I<INTERFACE_METHOD_TO> type must be greater than or equal to the length of the required arguments the method of the I<INSTANT_METHOD_TYPE_FROM> type. | ||
| 1737 | |||
| 1738 | The every argument other than at 0 index of the method of the I<INSTANT_METHOD_TYPE_FROM> must satisfy L<assignment requirement|/"Assignment Requirement"> to the argument as the same index of the method of the I<INTERFACE_METHOD_TO> without a data conversion and with interface exactly matched. | ||
| 1739 | |||
| 1740 | The return type of the method of the I<INSTANT_METHOD_TYPE_FROM> must must satisfy L<assignment requirement|/"Assignment Requirement"> to the return type of the method of the I<INTERFACE_METHOD_TO> without a data conversion and with interface exactly matched. | ||
| 1741 | |||
| 1742 | =head1 See Also | ||
| 1743 | |||
| 1744 | =over 2 | ||
| 1745 | |||
| 1746 | =item * L<SPVM::Document::Language::Class> | ||
| 1747 | |||
| 1748 | =item * L<SPVM::Document::Language::Operators> | ||
| 1749 | |||
| 1750 | =item * L<SPVM::Document::Language::Statements> | ||
| 1751 | |||
| 1752 | =item * L<SPVM::Document::Language> | ||
| 1753 | |||
| 1754 | =item * L<SPVM::Document> | ||
| 1755 | |||
| 1756 | =back | ||
| 1757 | |||
| 1758 | =head1 Copyright & License | ||
| 1759 | |||
| 1760 | Copyright (c) 2023 Yuki Kimoto | ||
| 1761 | |||
| 1762 | MIT License |