[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fflush & close behavior not well-defined

From: Andrew J. Schorr
Subject: Re: fflush & close behavior not well-defined
Date: Mon, 14 Sep 2020 14:18:43 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Sep 14, 2020 at 01:09:09PM -0500, Neil R. Ormos wrote:
> That is what I was suggesting.  I imagined that
> once the file had been opened, all that would be
> needed to update the global variable, for each
> I/O, would be to copy a pointer, which operation I
> further imagined to be so cheap, compared to
> actually launching the I/O, as to be "in the
> noise".
> Since you know the internals and I don't, I defer.

I don't think we want a new reserved global variable name, so we'd have to
stick it somewhere in PROCINFO. It's probably pretty cheap to do so, as you
suggest, but it feels inelegant to me.

> >> Then, a user who needs a non-ambiguous call to
> >> close() or fflush() could pass the handle instead
> >> of, or in addition to, the current filename
> >> argument?
> > I don't see why this is better than enhancing
> > the close & fflush functions to give them the
> > info they need to find the correct file, but
> > maybe if you flesh out your idea with an
> > example, I'll understand better.
> I'm not sure it's /better/.  It just seems
> /cleaner/ to let the user account for and supply a
> single unambiguous identifier, than to require the
> user to supply both the name and type of the
> something that is to be close()-d or fflush()-ed,
> and then for close() or fflush() to hunt around
> for a match.

Unfortunately, awk does not have a concept of file handles, most likely because
there's no formal open statement. So yeah, we could materialize this concept in
the background, but it would feel more elegant if there were a function for
this, e.g. filehandle_lookup(filename, filetype), rather than doing it behind
the scenes via PROCINFO.  In theory, we could probably implement such a
function in an extension, but it feels to me like a mess to introduce a concept
of hidden file handles.

> Again, I recognize that you know the internals and
> I don't.
> And that both you and Arnold see this as something
> nobody actually cares about.

I care a little bit. Arnold cares approximately zero, as
far as I can tell. :-) I'm putting it out there to check
the collective wisdom and raise awareness of this subtle


reply via email to

[Prev in Thread] Current Thread [Next in Thread]