Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 91 additions & 55 deletions docs/FEATURE_MATRIX.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
# Perl on JVM Feature Matrix

# Table of Contents
## Status Legend

- βœ… Fully implemented
- 🚧 Partially implemented
- 🟑 Implemented with limitations
- ❌ Not implemented

---

## Table of Contents

1. [Compiler Usability](#compiler-usability)
2. [Testing](#testing)
3. [Autovivification](#autovivification)
3. [Scalars](#scalars)
4. [Objects](#objects)
5. [Operators](#operators)
6. [Arrays, Hashes, and Lists](#arrays-hashes-and-lists)
7. [Subroutines](#subroutines)
8. [Regular Expressions](#regular-expressions)
9. [Statements and Special Operators](#statements-and-special-operators)
10. [I/O Operations](#io-operations)
11. [Namespaces and Global Variables](#namespaces-and-global-variables)
12. [Perl Modules, Pragmas, Features](#perl-modules-pragmas-features)
- [Pragmas](#pragmas)
- [Core modules](#core-modules)
- [Non-core modules](#non-core-modules)
- [DBI module](#dbi-module)
13. [Non-strict and Obsolete Features](#non-strict-and-obsolete-features)
14. [Features Probably Incompatible with JVM](#features-probably-incompatible-with-jvm)
15. [Language Differences and Workarounds](#language-differences-and-workarounds)
16. [Optimizations](#optimizations)
4. [Scalars](#scalars)
5. [Objects](#objects)
6. [Operators](#operators)
7. [Arrays, Hashes, and Lists](#arrays-hashes-and-lists)
8. [Subroutines](#subroutines)
9. [Regular Expressions](#regular-expressions)
10. [Statements and Special Operators](#statements-and-special-operators)
11. [I/O Operations](#io-operations)
12. [Namespaces and Global Variables](#namespaces-and-global-variables)
13. [Perl Modules, Pragmas, Features](#perl-modules-pragmas-features)
- [Pragmas](#pragmas)
- [Core modules](#core-modules)
- [Non-core modules](#non-core-modules)
- [DBI module](#dbi-module)
14. [Features Incompatible with JVM](#features-incompatible-with-jvm)
15. [Optimizations](#optimizations)

---

## Summary

Expand Down Expand Up @@ -50,6 +59,8 @@ PerlOnJava implements most core Perl features with some key differences:
- Threading
- DESTROY blocks

---

## Compiler Usability
- βœ… **Wrapper scripts**: (jperl/jperl.bat) for easier command-line usage.
- βœ… **Perl-like compile-time error messages**: Error messages mimic those in Perl for consistency.
Expand All @@ -58,7 +69,7 @@ PerlOnJava implements most core Perl features with some key differences:
- βœ… **Comments**: Support for comments and POD (documentation) in code is implemented.
- βœ… **Environment**: Support for `PERL5LIB`, `PERL5OPT` environment variables.
- 🚧 **Perl-like warnings**: Warnings is work in progress. Some warnings need to be formatted to resemble Perl's output.
- ❌ **Perl debugger**: The built-in Perl debugger (`perl -d`) is not implemented..
- ❌ **Perl debugger**: The built-in Perl debugger (`perl -d`) is not implemented.


### Command line switches
Expand All @@ -81,10 +92,13 @@ PerlOnJava implements most core Perl features with some key differences:
- `-D[number/list]`: Sets debugging flags.
- `-C [number/list]`: Controls Unicode features.

---

## Testing
- βœ… **TAP tests**: Running standard Perl testing protocol.
- βœ… **CI/CD**: Github testing pipeline in Ubuntu and Windows.

---

## Autovivification

Expand Down Expand Up @@ -120,6 +134,7 @@ my @reversed = reverse @{$z}; # ERROR
my @copy = @{$z}; # ERROR
```

---

## Scalars
- βœ… **`my` variable declaration**: Local variables can be declared using `my`.
Expand All @@ -128,7 +143,7 @@ my @copy = @{$z}; # ERROR
- βœ… **`state` variable declaration**: State variables are implemented. State variables are initialized only once.
- βœ… **Declared references**: `my \$x`, `my(\@arr)`, `my(\%hash)` are implemented.
- βœ… **Variable assignment**: Basic variable assignment is implemented.
- βœ… **Basic types**: Support for integers, doubles, strings, v-strings, regex, CODE, undef, references is present.
- βœ… **Basic types**: Integers, doubles, strings, v-strings, regex, CODE, undef, and references are supported.
- βœ… **String Interpolation**: Both array and scalar string interpolation are supported.
- βœ… **String Interpolation escapes**: Handles escape sequences like `\n`, `\N{name}`, `\Q`, `\E`, `\U`, `\L`, `\u`, `\l` within interpolated strings.
- βœ… **String numification**: Strings can be converted to numbers automatically.
Expand All @@ -139,16 +154,18 @@ my @copy = @{$z}; # ERROR
- βœ… **References**: References to variables and data structures are supported.
- βœ… **Autovivification**: Autovivification is implemented.
- βœ… **File handles**: Support for file handles is implemented.
- βœ… **`local` special cases**: `local` works for typeglobs and filehandles.
- βœ… **`local` special cases**: `local` is implemented for typeglobs and filehandles.
- βœ… **Typeglob as hash**: `*$val{$k}` for `SCALAR`, `ARRAY`, `HASH`, `CODE`, `IO` is implemented.
- βœ… **Use string as a scalar reference**: Support for scalar references from strings is implemented.
- βœ… **Tied Scalars**: Support for tying scalars to classes is implemented.
- βœ… **Tied Scalars**: Support for tying scalars to classes is implemented. See also [Tied Arrays](#arrays-hashes-and-lists), [Tied Hashes](#arrays-hashes-and-lists), [Tied Handles](#io-operations).
- ❌ **Taint checks**: Support for taint checks is not implemented.
- ❌ **`local` special cases**: `local *HANDLE = *HANDLE` doesn't create a new typeglob.
- ❌ **Variable attributes**: Variable attributes are not yet supported.

---

## Objects
- βœ… **Objects**: Creating classes, method call syntax works.
- βœ… **Objects**: Creating classes and method call syntax are implemented.
- βœ… **Object operators**: `ref` and `bless`
- βœ… **Special variables**: `@ISA` is implemented.
- βœ… **Multiple Inheritance**: C3 method resolution is implemented.
Expand All @@ -158,51 +175,65 @@ my @copy = @{$z}; # ERROR
- βœ… **Autoload**: `AUTOLOAD` mechanism is implemented; `$AUTOLOAD` variable is implemented.
- βœ… **`class`**: `class` keyword fully supported with blocks.
- βœ… **Indirect object syntax** indirect object syntax is implemented.
- βœ… **`:isa`**: Class inheritance with version checking works.
- βœ… **`:isa`**: Class inheritance with version checking is implemented.
- βœ… **`method`**: Method declarations with automatic `$self`.
- βœ… **`field`**: Field declarations with all sigils supported.
- βœ… **`:param`**: Constructor parameter fields fully working.
- βœ… **`:reader`**: Reader methods with context awareness.
- βœ… **`ADJUST`**: `ADJUST` blocks with field transformation work.
- βœ… **Constructor generation**: Automatic `new()` method creation.
- βœ… **Field transformation**: Fields become `$self->{field}` in methods.
- βœ… **Lexical method calls**: `$self->&priv` syntax works.
- βœ… **Lexical method calls**: `$self->&priv` syntax is implemented.
- βœ… **Object stringification**: Shows OBJECT not HASH properly.
- βœ… **Field defaults**: Default values for fields work.
- βœ… **Field inheritance**: Parent class fields are inherited.
- 🟑 **`__CLASS__`**: Compile-time evaluation only, not runtime.
- 🟑 **Argument validation**: Limited by operator implementation issues.
- ❌ **`DESTROY`**: Destructor blocks not yet implemented.

---

## Operators

### Arithmetic and Comparison
- βœ… **Simple arithmetic**: Operators like `+`, `-`, `*`, and `%` are supported.
- βœ… **Numeric Comparison operators**: Comparison operators such as `==`, `!=`, `>`, `<`, etc., are implemented.
- βœ… **Chained operators**: Operations like `$x < $y <= $z` are implemented.
- βœ… **defined-or**: `//` operator.
- βœ… **low-precedence-xor**: `^^` and `^^=` operator.

### String Operators
- βœ… **String concat**: Concatenation of strings using `.` is supported.
- βœ… **String Comparison operators**: String comparison operators such as `eq`, `ne`, `lt`, `gt`, etc., are implemented.
- βœ… **`q`, `qq`, `qw`, `qx` String operators**: Various string quoting mechanisms are supported.
- βœ… **Bitwise operators**: Bitwise operations like `~`, `&`, `|`, `^`, `~.`, `&.`, `|.`, `^.`, `<<`, and `>>` are supported.
- βœ… **Bitwise operators**: Bitwise integer and string operations are implemented.
- βœ… **Bitwise operators return unsigned**: Emulate unsigned integers.
- βœ… **Autoincrement, Autodecrement; String increment**: Increment and decrement operators, including for strings, are implemented.
- βœ… **Scalar string and math operators**: `quotemeta`, `ref`, `undef`, `log`, `rand`, `oct`, `hex`, `ord`, `chr`, `int`, `sqrt`, `cos`, `sin`, `exp`, `atan2`, `lc`, `lcfirst`, `uc`, `ucfirst`, `chop`, `fc`, `index`, `rindex`, `prototype`.
- βœ… **`join`**: Join operator for combining array elements into a string is supported.
- βœ… **`sprintf`**: String formatting is supported.
- βœ… **`substr`**: Substring extraction is implemented.
- βœ… **Lvalue `substr`**: Assignable Substring extraction is implemented.
- βœ… **`chomp`**: `chomp` is implemented.

### Bitwise Operators
- βœ… **Bitwise operators**: Bitwise operations like `~`, `&`, `|`, `^`, `~.`, `&.`, `|.`, `^.`, `<<`, and `>>` are supported.
- βœ… **Bitwise operators**: Bitwise integer and string operations are implemented.
- βœ… **Bitwise operators return unsigned**: Emulate unsigned integers.
- βœ… **Vectors**: `vec` is implemented.
- βœ… **Lvalue `vec`**: Assignable `vec` is implemented.

### List and Array Operators
- βœ… **`grep`, `map`, `sort`**: List processing functions are implemented.
- βœ… **`substr`**: Substring extraction works.
- βœ… **Time-related functions**: `time`, `times`, `gmtime`, `localtime` are implemented.
- βœ… **`pack` and `unpack` operators**: `pack` and `unpack` are implemented.

### Other Operators
- βœ… **Autoincrement, Autodecrement; String increment**: Increment and decrement operators, including for strings, are implemented.
- βœ… **Time-related functions**: `time`, `times`, `gmtime`, `localtime` are implemented.
- βœ… **`crypt` operator**: `crypt` is implemented.
- βœ… **`study`, `srand`**: `study`, `srand` are implemented.
- βœ… **`chomp`**: `chomp` is implemented.
- βœ… **`sleep`**: `sleep` is implemented. It takes fractional seconds.
- βœ… **`alarm`**: `alarm` is implemented with `$SIG{ALRM}` signal handling support.
- βœ… **`stat`**: `stat`, `lstat` are implemented. Some fields are not available in JVM and return `undef`.
- βœ… **Vectors**: `vec` is implemented.
- βœ… **Lvalue `substr`**: Assignable Substring extraction is implemented.
- βœ… **Lvalue `vec`**: Assignable `vec` is implemented.
- βœ… **Chained operators**: operations like `$x < $y <= $z` are implemented.

---

## Arrays, Hashes, and Lists
- βœ… **Array, Hash, and List infrastructure**: Basic infrastructure for arrays, hashes, and lists is implemented.
Expand All @@ -217,7 +248,7 @@ my @copy = @{$z}; # ERROR
- βœ… **`scalar`**: Operator to get scalar value is implemented.
- βœ… **Array dereference**: Dereferencing arrays using `@$x`.
- βœ… **Hash dereference**: Dereferencing hashes using `%$x`.
- βœ… **Dereference with $$var{...}**: Dereferencing using `$$var{...}` and `$$var[...]` works.
- βœ… **Dereference with $$var{...}**: Dereferencing using `$$var{...}` and `$$var[...]` is implemented.
- βœ… **Basic Array Operations**: `push`, `unshift`, `pop`, `shift`, `splice`, `reverse` are implemented.
- βœ… **Slices**: Array and Hash slices like `@array[2, 3]`, `@hash{"a", "b"}` and `%hash{"a", "b"}` are implemented.
- βœ… **Array literals**: Array literals are supported.
Expand All @@ -228,8 +259,10 @@ my @copy = @{$z}; # ERROR
- βœ… **`$#array`**: Lvalue array count is implemented: `$#{$sl} = 10`.
- βœ… **Array exists**: `exists` for array indexes is implemented.
- βœ… **Array delete**: `delete` for array indexes is implemented.
- βœ… **Tied Arrays**: Tied arrays are implemented.
- βœ… **Tied Hashes**: Tied hashes are implemented.
- βœ… **Tied Arrays**: Tied arrays are implemented. See also [Tied Scalars](#scalars), [Tied Hashes](#arrays-hashes-and-lists), [Tied Handles](#io-operations).
- βœ… **Tied Hashes**: Tied hashes are implemented. See also [Tied Scalars](#scalars), [Tied Arrays](#arrays-hashes-and-lists), [Tied Handles](#io-operations).

---

## Subroutines
- βœ… **Subroutine hoisting**: Invoking subroutines before their actual declaration in the code.
Expand All @@ -252,6 +285,8 @@ my @copy = @{$z}; # ERROR
- 🚧 **Subroutine attributes**: `prototype` is implemented. Other subroutine attributes are not yet supported.
- ❌ **CORE operator references**: Taking a reference to a `CORE` operator is not implemented: `BEGIN { *shove = \&CORE::push; } shove @array, 1,2,3;`

---

## Regular Expressions
- βœ… **Basic Matching**: Operators `qr//`, `m//`, `s///`, `split` are implemented.
- βœ… **Regex modifiers**: Modifiers `/p` `/i` `/m` `/s` `/n` `/g` `/c` `/r` `/e` `/ee` `/x` `/xx` are implemented.
Expand Down Expand Up @@ -282,7 +317,7 @@ my @copy = @{$z}; # ERROR
- βœ… **Possessive Quantifiers**: Quantifiers like `*+`, `++`, `?+`, or `{n,m}+`, which disable backtracking, are not supported.
- βœ… **Atomic Grouping**: Use of `(?>...)` for atomic groups is supported.
- βœ… **Preprocessor**: `\Q`, `\L`, `\U`, `\l`, `\u`, `\E` are preprocessed in regex.
- βœ… **Overloading**: `qr` overloading is implemented.
- βœ… **Overloading**: `qr` overloading is implemented. See also [overload pragma](#pragmas).

### Missing Regular Expression Features

Expand Down Expand Up @@ -348,8 +383,8 @@ my @copy = @{$z}; # ERROR
- βœ… **`require` operator**: `pmc` files are supported.
- βœ… **`use` and `no` statements**: Module imports and version check via `use` and `no` are implemented; version checks are implemented. `use` arguments are executed at compile-time.
- βœ… **`use version`**: `use version` enables the corresponding features, strictures, and warnings.
- βœ… **Import methods**: `import`, `unimport` works.
- βœ… **`__SUB__`**: The `__SUB__` keyword works.
- βœ… **Import methods**: `import` and `unimport` are implemented.
- βœ… **`__SUB__`**: The `__SUB__` keyword is implemented.
- βœ… **`BEGIN` block**: `BEGIN` special block is implemented.
- βœ… **`END` block**: `END` special block is implemented.
- βœ… **`INIT`**: special block is implemented.
Expand Down Expand Up @@ -395,6 +430,8 @@ my @copy = @{$z}; # ERROR
- βœ… **`format` operator**: `format` and `write` functions for report generation are implemented.
- βœ… **`formline` operator**: `formline` and `$^A` accumulator variable are implemented.

---

## I/O Operations

### Basic I/O Operators
Expand Down Expand Up @@ -426,8 +463,8 @@ my @copy = @{$z}; # ERROR
- βœ… **`chmod`**: File permissions.
- βœ… **`sysread`**
- βœ… **`syswrite`**
- βœ… **Tied Handles**: Tied file handles are implemented.
- βœ… **`DATA`**: `DATA` file handle works.
- βœ… **Tied Handles**: Tied file handles are implemented. See also [Tied Scalars](#scalars), [Tied Arrays](#arrays-hashes-and-lists), [Tied Hashes](#arrays-hashes-and-lists).
- βœ… **`DATA`**: `DATA` file handle is implemented.
- βœ… **`truncate`**: File truncation

### Socket Operations
Expand Down Expand Up @@ -482,10 +519,11 @@ The `:encoding()` layer supports all encodings provided by Java's `Charset.forNa
- `windows-1251` - Windows Cyrillic
- `KOI8-R` - Russian

---

## Namespaces and Global Variables
- βœ… **Global variable infrastructure**: Support for global variables is implemented.
- βœ… **Namespaces**: Namespace support is present.
- βœ… **Namespaces**: Namespace support is implemented.
- βœ… **Stash**: Stash can be accessed as a hash, like: `$namespace::{entry}`.
- βœ… **`@_` and `$@` special variables**: Special variables like `@_` and `$@` are supported.
- βœ… **Special variables**: The special variables `%ENV`, `@ARGV`, `@INC`, `$0`, `$_`, `$.`, `$]`, `$"`, `$\\`, `$,`, `$/`, `$$`, `$a`, `$b`, `$^O`, `$^V`, `$^X` are implemented.
Expand All @@ -500,6 +538,8 @@ The `:encoding()` layer supports all encodings provided by Java's `Charset.forNa
This means we don't include subroutine names in error messages yet.<br>
Extra debug information: `($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash)`

---

## Perl Modules, Pragmas, Features

- ❌ **No direct Perl-to-Java interoperability**: PerlOnJava does not provide Perl-side mechanisms like `Inline::Java` for directly calling Java methods or instantiating Java objects from Perl code. You cannot write Perl code that directly accesses arbitrary Java libraries or JVM languages.
Expand Down Expand Up @@ -654,12 +694,10 @@ The DBI module provides seamless integration with JDBC drivers:
#### Statement Handle Attributes
- `NAME`, `NAME_lc`, `NAME_uc`, `NUM_OF_FIELDS`, `NUM_OF_PARAMS`, `Database`


## Non-strict and Obsolete Features
- ❌ **DBM file support**: `dbmclose`, `dbmopen` are not implemented.
- ❌ **Calling a class name** `package Test; Test->()` gives `Undefined subroutine &Test::Test called`.
---

## Features Incompatible with JVM

- ❌ **`fork` operator**: `fork` is not implemented. Calling `fork` will always fail and return `undef`.
- ❌ **`DESTROY`**: Handling of object destruction may be incompatible with JVM garbage collection.
- For more details see: `dev/design/auto_close.md`.
Expand All @@ -668,12 +706,10 @@ The DBI module provides seamless integration with JDBC drivers:
- ❌ **Perl `XS` code**: XS code interfacing with C is not supported on the JVM.
- ❌ **Auto-close files**: File auto-close depends on handling of object destruction, may be incompatible with JVM garbage collection. All files are closed before the program ends.
- ❌ **Keywords related to the control flow of the Perl program**: `dump` operator.
- ❌ **DBM file support**: `dbmclose`, `dbmopen` are not implemented.
- ❌ **Calling a class name** `package Test; Test->()` gives `Undefined subroutine &Test::Test called`.


## Language Differences and Workarounds

This section is being worked on.

---

## Optimizations

Expand Down