develooper Front page | perl.perl5.porters | Postings from August 2001

Re: Adding callbacks to the core

Thread Previous
David M. Lloyd
August 20, 2001 12:58
Re: Adding callbacks to the core
Message ID:
On Mon, 20 Aug 2001, Paul Johnson wrote:

> On Mon, Aug 20, 2001 at 01:04:39PM -0500, David M. Lloyd wrote:
> > I was thinking about adding functionality like that given in my
> > Async::Callback module directly to the core of Perl, and I want to get
> > some thoughts and opinions.
> Maybe it would help if you were to explain what problem you are trying
> to solve.  What would be the benefit of adding this to the core over
> requiring people to use Async::Callback?  Could the problems be solved
> by having Async::Callback in the core?

My main concerns are: Async::Callback has to jump through some pretty
severe hoops to add a header file as part of the module distribution.
Also, it's kinda tough to make sure that a module like this stays
compatible with Perl; I have to duplicate Perl_runops_* in the module code
and these functions may change from one version of Perl to the next.  So
you could, by using Async::Callback, effectively replace part of your Perl
with that of another version!

As for putting Async::Callback in the core, it seems odd to duplicate the
core runops functionality in a module that is included with the core.
See below for other ideas.

> I can see some benefits to having the code in the core, mostly to do
> with ensuring both that the code is there and that it is known about
> and up to date.  My concern though is that the extra check in the
> red-hot op dispacth could affect speed too much.  And too much
> probably won't be all that much.  Does anyone remember the discussion
> about Chip's original safe signals patch?

I agree that this might be a problem.  One solution would be to make
callbacks a configuration setting.  Another (maybe better) solution is to
have a dynamically scoped "use callbacks;"/"no callbacks;" directive, with
the default being 'no'.  Then speed is not affected unless the user knows
what she is doing, but callbacks still have the various benefits of being
integrated into the core.  Also, backwards compatibility is not affected
at all in this case.

> I'm sure that a benchmark would help here.  How much is code slowed
> down in the normal case where there are no callbacks ever?

I'll work out a test implementation and maybe hack some benchmarks

- D


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