Interfaces in Perl5

By Kenta Kobayashi

Elevator Pitch

In this talk, I’d like to introduce Function::Interface. This module provides an Interface like Java and checks the arguments and return type of the function at compile time.

Besides, as organizer of YAPC::Tokyo 2019, I’d like to talk about recent YAPC and Perl communities in Japan.

Description

Have you ever experienced the software becoming bigger and less maintenance? In such a case, I think it is important to divide the code, make it easy to change, and make code easier to read.

For that reason, I thought the Interface was useful, and I made a module called Function::Interface.

Function::Interface checks the arguments and return type of the function at compile time. For example, you can write like this:

package IFoo {
    use Function::Interface;
    use Types::Standard -types;

    fun hello(Str $msg) :Return(Str);
}

package Foo {
    use Function::Interface::Impl qw(IFoo);

    use Types::Standard -types;
    use Function::Parameters;
    use Function::Return;

    fun hello(Str $msg) :Return(Str) {
        return "Hello! Pittsburgh! $msg"
    }
}

It’s strange but interesting!

TALK TOPICS:

  1. What is Interface, its importance
  2. How can I create Interface in Perl?
    • Role is not Interface
  3. DEMO Function::Interface
  4. Inside Function::Interface
    • Function::Parameters, Function::Return
    • Keyword::Simple, PPR