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

Reply via email to