Skip to Content.
Sympa Menu

devel - [sympa-developpers] New dependencies and boilerplate module

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Marc Chantreux <address@concealed>
  • To: address@concealed
  • Subject: [sympa-developpers] New dependencies and boilerplate module
  • Date: Thu, 30 Mar 2017 16:51:34 +0200

hello people,

sympa-rest-service will be powered by Dancer2 so every dependency of it
could be used. but i would like to go further. Don't hesitate to
disagree any of those ideas

* use strict; warnings and feature ':5.16' as default behaviour
(loaded from a boilerplate module)
* Moo should be used in every perl part of sympa (no more object written
by hand) in combinaison with Type::Tiny
* DBIx::Class should be used for the sympa-schema
* Path::Tiny should be used for file operations
* Dir::Self can help to remove some code preprocessing

Now ... yes racke we have to talk. in the Boilerplate module, i really
would like to require Function::Parameters (and one step further should
be Perlude).

I really would like to open my mind about it: yes, it could be a bit
slower but we can optimize a lot of things in sympa. What is critical
from my point of view is our codebase should be appealing for new
developpers and easier to maintain.

so ...

package User {
use Sympa;
use Moo;


has qw( name is rw )
, default => sub { "no one" };

method greetings ($who = "world") {
my $name = $self->name;
"hello $who from $name"
}

};

is the kind of things i would like to read when the perl 5.16 standard
for

method greetings ($who = "world") {
say "hello $who"
}

is actually

sub greetings ($;$) {
my $self = shift;
my $who = @_ ? shift : "no one";
my $name = $self->name;
"hello $who from $name"
}

in a code as large as the sympa one, those kind of readability
imprivement matters.

same for Perlude:

my @top5 = fold take 5, $stream;

is so much readable than

my @top5;
my $count = 5;

while ($count-- && defined (my $val = $stream->()) {
push @top5, my $val;
}


so my proposal for boilerplate module should be something like the
following one. please share your feelings about it.

marc


package Sympa;
use base 'Exporter';
use feature ':5.16';
use strict ();
use warnings ();
require Function::Parameters;
require Perlude;

use Import::Into;
our $VERSION = '0.0';

sub import {
my $caller = caller;

strict->import;
# warnings->import(FATAL => 'all');
warnings->import;
feature->import( ':5.14' );

Function::Parameters -> import::into($caller,':strict');
File::Slurp -> import::into($caller, ':all');
Perlude -> import::into($caller);
# List::AllUtils -> import::into($caller, qw< first any all >);
# IO::All->import::intro($caller);
}

1;


  • [sympa-developpers] New dependencies and boilerplate module, Marc Chantreux, 03/30/2017

Archive powered by MHonArc 2.6.19+.

Top of Page