develooper Front page | perl.perl5.porters | Postings from July 2016

async/await syntax - call to action

Thread Next
Paul "LeoNerd" Evans
July 1, 2016 21:15
async/await syntax - call to action
Message ID:
((This third of a three-part mail series contains the actual
  call-to-action; a request for p5p's assistance. See the first two
  mails for the background context and surrounding problem if you want
  to appreciate why, though it's not strictly necessary to help here.))

Everybody loves an Acme module.[citation needed]

In all seriousness; an Acme module is often an excellent way to show
how to perform *one* serious piece of behaviour, by wrapping it up in a
silly context. In order to work out how I can implement async/await I
would therefore love to see an implementation of a module that passes
this unit test:

  use Test::More plan => 3;

  use Acme::SupersizeMe;

  my $four;

  sub one { return 0 }
  sub five { return $four }
  sub ten { 3 * 3 }

    supersize $_ for \&one, \&five, \&ten;

  $four = 4;

  is( one(), 1, 'one() is 1' );
  is( five(), 5, 'five() is 5' );
  is( ten(), 10, 'ten() is 10' );


Specifically, the code inside the BEGIN block invokes 'supersize' on
those three functions, such that when executed, their eventual return
value is incremented by 1.

I would like this to be implemented by the code in 'supersize' (which I
imagine would have to be an XS function) mutating the CVs stored in the
&one, &five, and &ten globs themselves, so that any caller with any
reference to these functions will observe the same result. It is
further required that, if these so-modified functions are either
exported, or stand as object methods, that other callers to these
functions see the intended values (1, 5, 10) without themselves needing
to be aware of supersize in any way.

If you can help me implement that, then I can implement my 'async'
keyword, and thus be well on my way to bringing to Perl 5 the same
async/await syntax that ECMAScript, Python and C# all now enjoy.

Good luck,

Paul "LeoNerd" Evans      |  |

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About