Syntax::Construct

Syntax::Construct—explicitly declare the syntactic constructs your program uses.

E. Choroba

The Czech Republic, Prague

PerlMonks, CPAN, YouTube, …

choroba@matfyz.cz

Features

You want to use say in your program.

Features (2)

Non-features

You want to use the defined-or operator (//).

Non-features (2)

But...

Non-features (3)

Well, branch reset is an exception. Who would ever use it, anyway?

Solution?

#!/usr/bin/perl
use warnings;
use strict;

use Syntax::Construct qw(  //  ?|  );

Benefits for

Removals

5.24 will be the first Perl version to remove a non-feature.

my $h = { a => 12, b => 14 };
print keys $h;
Experimental keys on scalar is now forbidden at ...

Removals

5.24 will be the first Perl version to remove a non-feature.

my $h = { a => 12, b => 14 };
print keys $h;
Experimental keys on scalar is now forbidden at ...

But after prepending

use Syntax::Construct qw{ auto-deref };

The error message in 5.23.3 is different:

Faking version 5.024 to test removals.
auto-deref removed in 5.024 at ...
BEGIN failed--compilation aborted at ...

The Name

What's in a name? that which we call a rose
By any other name would smell as sweet

The Implementation

Very simple.

We store all the non-features in a hash with their corresponding minimal Perl versions. In the import method, we just require the maximal version in a block eval.

UTSL

Testing

Each construct is

See GitHub.

Should Syntax::Construct Replace feature?

Current Status

Thank you.

https://e-choroba.eu/15-yapc

Questions?