Perl Subroutine Signatures Opinion Blog

This site is an opinion blog about Perl Subroutine Signatures. Subroutine Signatures is plan to added to Perl in the near future. I have a very strong concern in the future of Perl, so I created an independent site about sub signatures. My name is Yuki Kimoto. I'm Perl Light User. I have no media power, community power, political power, and big company power. I just feel and talk about the heart of a weak perl user without a voice.

Are array and hash representations really needed?

Are array and hash representations really needed?

Currently, "@foo" is proposed as the array representation. "%foo" is proposed as the representation of the hash.

# Array representation
sub (@foo) {
  
}
sub ($var, @foo) {
  
}

# Hash representation
sub (%foo) {
  
}

sub ($var, %foo) {
  
}

Are these always necessary?

Alternative representation using only scalar variables

You can rewrite the above array and hash representation using only scalar variables if you need copy.

# Array representation
sub ($foo) {
  my @foo = @$foo;
  
}
sub ($var, $foo) {
  my @foo = @$foo;
}

# Hash representation
sub ($foo) {
  my %foo = %$foo;
}
sub ($var, $foo) {
  my %foo = %$foo;
}

In many languages, array and hash passed as a reference

In many languages, array and hash passed as a reference.

JavaScript Function Definition

At first, see JavaScript code. foo function definition.

function foo (nums, opt) {
  
}

Ruby Function Definition

Next, see Ruby code of foo function definition.

def foo (nums, opt)
  
end

Python Function Definition

Next, see Python code of foo function definition.

def foo (nums, opt)
  

PHP Function Definition

Next, see PHP code of foo function definition.

function foo ($nums, $opt) {

}

Perl

Subroutine signature of Perl is special.

sub ($var, @foo) {
  
}

sub ($var, %foo) {
  
}

In fact, current Perl already have reference different from past Perl.

If it is limited to only scalar variables as arguments of subroutine signatures, alternative expressions are possible.

What is benefit of limited only scalar variables?

What is benefit of limited only scalar variables?

The biggest benefit is that the subroutine signature is very simple.

Perl is already big and complex.

External people feel that Perl is already difficult to read and complex.

Therefore, the subroutine signature specification, which is easy to understand, gives good evaluation when viewed from outside.

The Perl internal community may be frustrated.

What is good balance?