On 07.09.2012 12:30, Aharon Robbins wrote:
> Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
>>> I think that it would be nice if "close(FILENAME)" would make the
>>> (non-standard) 'nextfile' obsolete. (Can't tell, though, whether
>>> such a change would break any existing programs.)
>
> It undoubtedly would,
While I can't tell I still have my doubts. I am trying to think of a
situation where one would have programmed close(FILENAME) or close(var)
where var is corresponding to FILENAME, a file name passed as argument.
And function close() operates on "a file or pipe opened for output".
So to get some conflicting situation you'd have to close a redirected
file that's also a parameter file that you want to skip. A potentially
useful redirection into a file that's also a parameter might be, e.g.,
awk 'NR==FNR { ... } NR!=FNR { print > "param1" }' param1 param2
Now where would an added close(FILENAME) break such programs? Hmm...
Or is there maybe some simpler example that would obviously break?
Can anyone suggest some sensible construct which would break?
> and it would not be portable amongst awks,
> even though it doesn't use any non-standard keywords.
Well, in the context of non-standard 'nextfile' portability is not my
primary concern. Generally, whenever we add a new function either way,
as an added functionality for close(), or an added keyword nextfile,
it's not portable. Any new non-standard function that has some effect
is not portable; is it?
> [...]
> Again - only in tawk. This caused some confusion many years ago, since
> in awk/gawk it doesn't return an error (closing a file that isn't open
> is a no-op) at which point I documented it explicitly that close()
> is just for redirections.
I don't recognise it, but does that fact (the error return code) break
an added close(FILENAME) "skip file" functionality?
Reading in A.W.K.'s original book about close() also doesn't indicate
any problem for such a close(FILENAME) extension.
But since Aharon seems to have a strong opinion on that, I assume that
I still missed something, something that's maybe even obvious after some
more coffee. Any enlightenments appreciated.
Janis
> [...]