Hi all,

Thanks to Schwern's recent work on Method::Signatures, something clicked with me. It looks like Devel::Declare (dangerous as it is) allows for very pretty syntactic sugar, without relying on source filters.


Inspired by Method::Signatures, I've been hacking on something specifically for use with cgiapp.

  package My::App;

  use base 'CGI::Application';
  use Runmode::Declare; # proof-of-concept name

  startmode hello { "Hello" }
  runmode world { $self->hello . ", World!" }

Most of the time, you won't need to call setup() anymore, because this takes care of setting the start/run modes for you. Obviously, it checks that you only have one startmode. And it all works fine with inheritance too.


Using signatures:

  # script?rm=invite;party_id=42;names=larry;names=guido;names=matz

  runmode invite($party_id, @names) {
    my $party = party_from_id($party_id);
    $party->add_invitees(@names);
  }

  # somewhere else:
  $self->invite( 36, qw(me myself I) );

This pulls the named parameters from @_, or $self->query->param, or 
$self->param.


Rename the methods (probably silly, but it was easy and fun to try):

  use Runmode::Declare runmode => 'screen', startmode => 'splash';

  splash hello { "Hello" }
  screen world { "World!" }


Is anyone interested in seeing this on CPAN? Or should I just keep this to myself, and report back to the asylum? :-)


rhesa

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to