Arc Forumnew | comments | leaders | submit | ap's commentslogin

Using Catalyst, a Perl version might look like this:

  package ArcChallenge;
  use strict;
  use Catalyst;
  use Catalyst::Action::REST;
  
  my @said;
  
  sub index : Action ActionClass('REST') {}
  
  sub index_GET {
      my ($self, $c) = @_;
      $c->res->body( "<form method=post><input name=said><input type=submit>" );
  }
  
  sub index_POST {
      my ($self, $c) = @_;
      my $n = push @said, $c->req->params->{said};
      $c->res->body( "<a href='/said/$n'>Click Here</a>" );
  }
  
  sub said : Regex('^said/(\d+)$') {
      my ($self, $c) = @_;
      $c->res->body( $said[ $c->req->captures->[0] - 1 ] );
  }
  
  __PACKAGE__->setup;
  
  1;
Bit clunky as yet, but work's underway to tersen up the syntax. (For anyone interested in how this will be implemented under the hood, the magic CPAN incantation is Devel::Declare. However it's a months-old work in progress so docs are minimal.) Once done it will remove most of the repeated boilerplate bits in the above code (eg. the assignments from @_ to unpack the parameters).

-----

2 points by hobbified 5919 days ago | link

  package CatArc;
  
  use strict;
  use warnings;
  
  use Catalyst qw/Session Session::Store::FastMmap Session::State::Cookie/;

  our $VERSION = '3.14159265359';
  
  __PACKAGE__->setup;
  
  sub index : Index { } # No need to do anything
  
  sub landing : Local {
    my ( $self, $c ) = @_;
    $c->flash->{said} = $c->req->params->{said};
  }
  
  sub display : Local { } # Do nothing
  
  sub end : ActionClass('RenderView') { } # Do a magical nothing.
  
  1;
Plus templates, for crying out loud. They exist for a reason. TT used for the sake of "everyone knows it": index.tt and landing.tt are as good as static, containing just a form and a link resp. display.tt contains "You said: [% c.flash.said %]".

-----

4 points by ap 5926 days ago | link | parent | on: The Trouble with Arc's Lack of Unicode Support

> I don't think it's an accident that so many successful languages have had trouble later with strings.

Of course. The obvious reason is that all of them are at least as old as Unicode itself.

Unicode awareness was not even looming on the horizon when they were first created. Citing their initial lack of Unicode awareness as support for any theory about language success is... well, it's a number of things, but "relevant" is not of them, and I'm honestly puzzled as to what would lead you to think otherwise.

-----