Hi Ovid.
Although my module nearly duplicates Attribute::Context I'm inclined
to proceed. Because if anything, the challenge is to accurately
define the problem. The solution is fairly trivial. Consequently, a
good module name might be the most significant improvement for me to
pursue.
I propose Contextual::Return::Wrapper. While it's not perfect, here's
the reasoning:
The CPAN taxonomy reflects a problem domain structure. That is, CPAN
allows users to describe a problem and then delivers a solution module.
Damian Conway's Contextual::Return module falls in the same problem domain
as the wantarray built-in by offering a more granular solution. My module
also extends wantarray by implementing predefined functionality.
Admittedly, Wantarray::Wrapper might even be better: My module
automatically implements wantarrary functionality by wrapping "sub" magic
around an implementer function.
Contextual::Return is literally synonymous with wantarray, so
Contextual::Return::Wrapper seems literally acceptable. However, since
the name Contextual::Return doesn't clearly distinguish Damian's module
from the wantarray built-in, Contextual::Return::Wrapper gives the
mistaken impression that my module extends Damian's. Which it does not.
So the pros and cons of Wantarray::Wrapper vs Contextual::Return::Wrapper
boils down to creating another top level name space and separating these
two modules into separate problem domains. Seems like a question for the
experts.
Thanks!
-Jim
On Fri, 26 Jul 2013, Ovid wrote:
Since you're asking about related modules, I have an Attribute::Context
module on the CPAN. I released it years ago, no one used it, so now test
failures are piling up with newerreleases:
http://search.cpan.org/dist/Attribute-Context/lib/Attribute/Conte
xt.pm
Maybe that will help?
Cheers,
Ovid
--
IT consulting, training, international recruiting
http://www.allaroundtheworld.fr/.
Buy my book! - http://bit.ly/beginning_perl
Live and work overseas - http://www.overseas-exile.com/
____________________________________________________________________________
From: Jim Schueler <j...@tqis.com>
To: module-authors@perl.org
Cc: j...@tqis.com
Sent: Tuesday, 23 July 2013, 16:37
Subject: Name for pragma type module?
Hello.
I would like to publish the modules described below. In particular,
I'm
requesting recommendations for a good name.
Frequently I write simple mutators as functions. The mutator should
return
a scalar when a scalar is passed and a list when a list is passed. I
was
looking for an existing solution, and concluding there was none, wrote
my
own. This module defines two function attributes as shown below:
## Example uses "lc" to represent an arbitrarily complex mutator
sub lowercase : ScalarContext('first') {
return map { lc } @_ ;
}
print scalar lowercase('Jim'), "\n" ; ## prints 'jim' instead of
1
There several variants:
sub lowercase : ScalarContext('last') {...} ## returns the last
element
sub lowercase : ScalarContext('count') {...} ## default behavior
sub lowercase : Listify {...} ## aristotle's response
The Listify attribute was added after someone recommended "pasting a
listify()
function in every project" instead of this module. Maybe this is
common
practice; and if so, wouldn't a CPAN module be preferable?
One option is to release this module as a pragma. Note the difference
in
invocation:
## Function::ReturnScalar name used in blog example
use Function::ReturnScalar ; ## pragma
use base Function::ReturnScalar ; ## standard
I've posted this discussion on perlmonks and perl blogs:
http://blogs.perl.org/users/jim_schueler/2013/07/function-return-in-scalar-
context.html
My question is basically:
1. Is there an existing module? (Apparently not)
2. Is this module useful to anyone else?
3. Code review of proposed solution
I was hoping for more encouraging responses, which I've summarized as
follows:
1. Non-specific attacks unrelated to the question about usefulness.
2. Generally used work-arounds are better (without explanation).
3. A couple indications that the module would be useful.
Maybe these responses help test the moxie of a new wannabe
contributor?
Although the general response tone was discouraging, no one gave any
specific
reasons against release. And, at least, publishing this module will
help
*my* code base.
I'd like to release this module following all the best practices. Can
anyone
help?
Thanks!
-Jim