I've been thinking about this a lot and I wanted to run an idea past P5P. Corinna tremendously cleans up Perl's OOP capabilities. It would be nice to have something like that for procedural code. I have no sponsor for this, but I was thinking about a `module` keyword. It would complement Corinna syntax and look something like this:
module Some::Utilities :version(3.14) {
# all subs with an :export tag can be imported individually
# use Some::Utilities ':strings';
sub make_slug :export(strings) ($name) {
...
}
# use Some::Utilities ':numbers';
sub constrain :export(numbers) ( $min, $num, $max = undef ) {
...
}
# use Some::Utilities ':numbers';
sub weighted_pick :export(numbers) ($weight_for) {
...
}
# cannot be exported
sub _binary_range ( $elem, $list ) {
...
}
}
Benefits:
* Postfix block lexically scopes changes
* Strict, warnings, utf8 source, signatures, and "no feature 'indirect'" by default
* :export is handled natively leaving the import() free for other uses
* Yields a `1` to avoid needing to add `1` at the end of every file.
Deliberately limited in scope to make it smaller and easier to implement. I believe that with `module` and `class`, we have a solid foundation for releasing Perl 7.
Best,
Ovid
--
IT consulting, training, specializing in Perl, databases, and agile development
http://www.allaroundtheworld.fr/.
Buy my book! - http://bit.ly/beginning_perl
module Some::Utilities :version(3.14) {
# all subs with an :export tag can be imported individually
# use Some::Utilities ':strings';
sub make_slug :export(strings) ($name) {
...
}
# use Some::Utilities ':numbers';
sub constrain :export(numbers) ( $min, $num, $max = undef ) {
...
}
# use Some::Utilities ':numbers';
sub weighted_pick :export(numbers) ($weight_for) {
...
}
# cannot be exported
sub _binary_range ( $elem, $list ) {
...
}
}
Benefits:
* Postfix block lexically scopes changes
* Strict, warnings, utf8 source, signatures, and "no feature 'indirect'" by default
* :export is handled natively leaving the import() free for other uses
* Yields a `1` to avoid needing to add `1` at the end of every file.
Deliberately limited in scope to make it smaller and easier to implement. I believe that with `module` and `class`, we have a solid foundation for releasing Perl 7.
Best,
Ovid
--
IT consulting, training, specializing in Perl, databases, and agile development
http://www.allaroundtheworld.fr/.
Buy my book! - http://bit.ly/beginning_perl