[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Adding an API hook to enable a select extension
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] Adding an API hook to enable a select extension |
Date: |
Fri, 31 May 2013 07:54:43 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi Eli,
On Fri, May 31, 2013 at 09:00:35AM +0300, Eli Zaretskii wrote:
> > Date: Thu, 30 May 2013 21:12:14 -0400
> > From: "Andrew J. Schorr" <address@hidden>
> >
> > At the risk of making Brian Kernighan throw up, since he believes no awk
> > program should be longer than 2 lines, I propose the attached patch to the
> > API.
> > I could be mistaken, but I think this should be enough to implement a select
> > extension. If the name argument is NULL, it would return &curfile.public.
> > Otherwise, it would return &getredirect(name, strlen(name))->iop->public.
> > We
> > might want to replace the red_head array with a hash table to optimize the
> > performance of getredirect.
> >
> > User code might look something like this:
>
> Is it really a good idea to leak such low-level details to Gawk
> program level? Can't we come up with some higher-level abstraction
> for this, like conceal the entire while(1) loop in Gawk internals, and
> present just some operator or function(s) on the Gawk script level?
The first question is whether to extend the API as I have proposed.
The next question is how the extension should work. I think you are
objecting to providing a "select" function to the user. I guess the
alternative is to provide a standardized event dispatching mechanism.
Such a mechanism could easily be provided in gawk user code that sits
on top of the low-level select function that I proposed.
In other words, I think it makes sense to use the extension capability
to provide the well-known select mechanism. We will then have the
ability to build libraries on top of it that package it as desired.
I note that read timeouts do not work on MinGw and VMS because select is
apparently not available, or so it appears from the code in
io.c:read_with_timeout.
Is there some alternative event dispatching mechanism that works on these
platforms? If so, I guess it could make sense to provide a higher-level
API that can work on those platforms as well. If not, I think the right
thing to do is provide select and allow packages to be built on top of
that.
Regards,
Andy
- [bug-gawk] Issue with read timeout on TCP socket, Serge A. Zaitsev, 2013/05/29
- Re: [bug-gawk] Issue with read timeout on TCP socket, Davide Brini, 2013/05/30
- Re: [bug-gawk] Issue with read timeout on TCP socket, Andrew J. Schorr, 2013/05/30
- Re: [bug-gawk] Adding an API hook to enable a select extension, Andrew J. Schorr, 2013/05/30
- Re: [bug-gawk] Adding an API hook to enable a select extension, Eli Zaretskii, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension,
Andrew J. Schorr <=
- Re: [bug-gawk] Adding an API hook to enable a select extension, Aharon Robbins, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Eli Zaretskii, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Andrew J. Schorr, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Eli Zaretskii, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Andrew J. Schorr, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Eli Zaretskii, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Andrew J. Schorr, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Eli Zaretskii, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Andrew J. Schorr, 2013/05/31
- Re: [bug-gawk] Adding an API hook to enable a select extension, Eli Zaretskii, 2013/05/31