>
> 3) Promises instead of continuation-passing style for non-blocking APIs. 
> Does it make sense? Is it the future? How would it look like?
>

In case it's not clear how this is a problem... most of our 
blocking/non-blocking hybrid methods take an optional CODE reference as 
last argument for switching between modes.

  # Blocking
  my $tx = $ua->get('mojolicio.us');

  # Non-blocking
  $ua->get('mojolicio.us' => sub {
    my ($ua, $tx) = @_;
  });

So there is not much room in the API for passing around promises, and they 
would most likely need their own methods.

  # Blocking
  my $tx = $ua->get('mojolicio.us');

  # Non-blocking
  $ua->aget('mojolicio.us')->then(sub {
    my $tx = shift;
  });

Another interesting question is where this would leave modules like 
Mojo::EventEmitter and callbacks that get invoked multiple times, Perl6 has 
this interesting concept of "Supplies". 
(http://perlcabal.org/syn/S17.html#Supplies)

  $ua->on('error')->tap(sub {
    my $err = shift;
  });

  Mojo::IOLoop->listen(port => 3000)->tap(sub {
    my $stream = shift;
  });

Perl6 uses Promises very extensively, so this is going to be an important 
topic for a Mojolicious port too. 
(http://perlcabal.org/syn/S17.html#Promises)

--
sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to