develooper Front page | perl.perl5.porters | Postings from October 2012

The future of features and pragmata

Thread Next
From:
Johan Vromans
Date:
October 29, 2012 06:19
Subject:
The future of features and pragmata
Message ID:
m2txtd4dr3.fsf@phoenix.squirrel.nl
From perldoc perlpragma:

  A pragma is a module which influences some aspect of the compile time
  or run time behaviour of Perl, such as "strict" or "warnings".

From perldoc feature:

  It is usually impossible to add new syntax to Perl without breaking
  some existing programs. This pragma provides a way to minimize that
  risk. New syntactic constructs, or new semantic meanings to older
  constructs, can be enabled by "use feature 'foo'", and will be parsed
  only when the appropriate feature pragma is in scope.[1]

There seems to be an overlap between these two.

Most pragmata apply to run-time behaviour[2], autodie, bigint, bytes,
filetest, integer, and so on.

There is a feature that modifies run-time behaviour, just like the
pragmata: unicode_strings.

It may be worth considering to add a pragma for unicode_strings and
delete it (by deprecation) from the features. Alternatively, it might be
equally worth considering moving (by deprecation) suitable pragmata to
features. For a novice Perl user, it seems more natural to use:

  use feature qw(unicode_strings integer);

than

  use feature qw(unicode_strings);
  use integer;

Pragmata suitable to become features (quick and dirty list, may contain
errors): autodie, bigint, bignum, bigrat, bytes, deprecate, filetest,
integer, locale, open, utf8.

Thanks for your attention.

-- Johan

Notes:

[1] The wording suggests that feature was intended to change syntaxis
only, and that changing semantic meanings was added afterwards.

[2] While there may be compile-time issues involved internally, user
perceivable changes are run-time only.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About