[cgiapp] ($self vs $c) was: Re: New Plugin: RunmodeDeclare

Mark Stosberg mark at summersault.com
Sun Sep 28 20:19:55 EDT 2008


On Mon, 29 Sep 2008 00:18:02 +0100
Richard Jones <ra.jones at dpw.clara.co.uk> wrote:

> Mark Stosberg wrote:
> > As Rhesa proposed, he has followed through and released a plugin to add the
> > Devel::Declare / Method::Signatures magic to CGI::Application:
> > 
> > http://search.cpan.org/perldoc?CGI::Application::Plugin::RunmodeDeclare
> 
> Looks like an interesting alternative to CAP::AutoRunmode. One minor 
> irritant is having to put 'runmode foo ($c:)' everywhere (only if using 
> $c instead of $self of course). Might be useful to be able to declare 
> use CGI::Application::Plugin::RunmodeDeclare(invocant => '$c'), or just 
> use CAP::RunmodeDeclare qw($c).

I agree with this sentiment.

This brings back to life the discussion we were having on IRC the other
day about "$self" vs "$c".  

I like "$c" because it's shorter and since it's used all over the code
base, it's clear enough what it is. And, the first element to 'shift'
off of @_ in a method must be the invocant. 

Michael Peters and Richardo argued in favor of "$self" citing the
"Principle of Least Surprise" and the expectation that this non-standard
change would generate more harm in confusion than benefits in
keystrokes. 

Although I still prefer "$c" in my own code, I thought they made good
points, so I switched back from "$c" to "$self" in the docs and code of
the latest CGI::App dev release. 

But I'm interested in more opinions on the issue. Richard, do you
particularlly prefer "$c", or were you mostly following along the docs
that were updated to switch from "$self" to "$c" ?

    Mark

-- 
http://mark.stosberg.com/blog





More information about the cgiapp mailing list