Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Second beta release towards gawk 4.1.2

90 views
Skip to first unread message

Aharon Robbins

unread,
Apr 16, 2015, 3:17:40 PM4/16/15
to
This note is to announce the second BETA release of GNU Awk 4.1.2.

It is available from:

http://www.skeeve.com/gawk/gawk-4.1.1d.tar.gz

This is a bug-fix release.

So, why do a beta release? So that you, yes you, the end user, can see
if anything I've done breaks gawk for you. Then you can TELL ME ABOUT
IT so that I can fix it for the final release.

Please send feedback ASAP. I want to make a real release by next
week if possible.

Thanks,

Arnold Robbins
arn...@skeeve.com
---------------------------------------------
Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015,
Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

Changes from 4.1.1 to 4.1.2
---------------------------

1. The manual has been considerably improved.
- Thoroughly reviewed and updated.
- Out-of-date examples replaced.
- Chapter 15 on MPFR reworked.
- Summary sections added to all chapters.
- Exercises added in several chapters.
- Heavily proof-read and copyedited.

2. The debugger's "restart" command now works again.

3. Redirected getline is now allowed inside BEGINFILE/ENDFILE.

4. A number of bugs have been fixed in the MPFR code.

5. Indirect function calls now work for both built-in and extension functions.

6. Built-in functions are now included in FUNCTAB.

7. POSIX and historical practice require the exclusive use of the English
alphabet in identifiers. In non-English locales, it was accidentally
possible to use "letters" beside those of the English alphabet. This
has been fixed. (isalpha and isalnum are NOT our friends.)

If you feel that you must have this misfeature, use `configure --help'
to see what option to use when configuring gawk to reenable it.

8. The "where" command has been added to the debugger as an alias
for "backtrace". This will make life easier for long-time GDB users.

9. Gawk no longer explicitly checks the current directory after doing
a path search of AWKPATH. The default value continues to have "." at
the front, so most people should not be affected. If you have your own
AWKPATH setting, be sure to put "." in it somewhere. The documentation
has been updated and clarified.

10. Infrastructure upgrades: Automake 1.15, Gettext 0.19.4, Libtool 2.4.6,
Bison 3.0.4.

11. If a user-defined function has a parameter with the same name as another
user-defined function, it is no longer possible to call the second
function from inside the first.

12. POSIX requires that the names of function parameters not be the
same as any of the special built-in variables and also not conflict
with the names of any functions. Gawk has checked for the former
since 3.1.7. With --posix, it now also checks for the latter.

13. A number of bugs have been fixed. See the ChangeLog.
--
Aharon (Arnold) Robbins arnold AT skeeve DOT com

pjfarley3

unread,
Apr 19, 2015, 9:50:25 AM4/19/15
to
On Thursday, April 16, 2015 at 3:17:40 PM UTC-4, Aharon Robbins wrote:
> This note is to announce the second BETA release of GNU Awk 4.1.2.
>
> It is available from:
>
> http://www.skeeve.com/gawk/gawk-4.1.1d.tar.gz

Arnold,

Maybe it's my ISP's DNS servers but I can't get the tarball - Firefox and IE both say they cannot find www.skeeve,com, and I can't ping or tracert to it either.

Is it something I am doing or not doing?

Peter

Aharon Robbins

unread,
Apr 19, 2015, 10:51:03 AM4/19/15
to
There are some problems with the machine hosting www.skeeve.com.
I don't know what they are. I hope they'll be fixed soon. In the
meantime, as always, the code base is available from the Git repo
on Savannah. Use the gawk-4.1-stable branch.

Arnold

In article <ce8db04b-4f4c-42de...@googlegroups.com>,

pjfarley3

unread,
Apr 19, 2015, 3:10:48 PM4/19/15
to
On Sunday, April 19, 2015 at 10:51:03 AM UTC-4, Aharon Robbins wrote:
> There are some problems with the machine hosting www.skeeve.com.
> I don't know what they are. I hope they'll be fixed soon. In the
> meantime, as always, the code base is available from the Git repo
> on Savannah. Use the gawk-4.1-stable branch.
>
> Arnold

And now they seem to have cleared up and I was able to get the tarball.

Thanks for reminding me about the git repository.

Peter

Anton Treuenfels

unread,
Apr 24, 2015, 10:24:40 AM4/24/15
to

"Aharon Robbins" <arn...@skeeve.com> wrote in message
news:mgp1qp$p3u$1...@dont-email.me...
> This note is to announce the second BETA release of GNU Awk 4.1.2.
> 5. Indirect function calls now work for both built-in and extension
> functions.

Speaking of indirect function calls, you might consider updating the
documentation a bit. The following program works fine with my copy of gawk64
for Windows:

=======================

# testing indirect function calls in gawk
# - can an array variable be used to hold the function name ?

function first_indirect() {

print "The first indirect function is called successfully"
}

function second_indirect() {

print "The second indirect function is called successfully"
}

BEGIN {

print "Indirect via scalar variable"

myindirect = "first_indirect"
@myindirect()
myindirect = "second_indirect"
@myindirect()

print "Indirect via numerically indexed array variable"

numndx[ 1 ] = "first_indirect"
numndx[ 2 ] = "second_indirect"

for ( i in numndx ) {
myindirect = numndx[ i ]
@myindirect()
}

print "Indirect via string indexed array variable"

strndx[ "first_indirect" ] = ""
strndx[ "second_indirect" ] = ""

for ( i in strndx ) {
myindirect = i
@myindirect()
}
}

====================

BUT the reason I wrote it was to test whether or not the variable holding
the function name could be an array variable. That is, could I write
something like this:

=====================

for ( i in numndx )
@numndx[ i ]()

=====================

The answer is no, I cannot. Syntax errors abound. But that is not something
I could find out from the documentation - I had to try it.

Given that the above does not work, I suppose it would be even more of a
nightmare to try to get something like this to work:

======================

for( i in strndx )
@i()

=======================

I didn't even try that. But I did make this mistake:

=======================

for ( i in strndx ) {
myindirect = strndx[ i ]
@myindirect()
}

=======================

which, since the contents of each strndx[] is the null string, didn't work
either. But it did upset gawk enough to "request being shut down in an
unusual way", according to the message on the screen.

- Anton Treuenfels

Kaz Kylheku

unread,
Apr 24, 2015, 10:43:45 AM4/24/15
to
On 2015-04-24, Anton Treuenfels <teamt...@yahoo.com> wrote:
> @myindirect()

So does that mean that Gawk is now a two-namespace language, like a "Lisp-2?"

That is to say, in the same scope, such as a function body, can a name X
have multiple bindings such that:

- X() # calls the defined function X
- X = 42 # assigns to the local variable
- @X() # calls the function stored in variable X

If X cannot have such multiple bindings (the local X shadows the function
definition) then having an explicit funcall operator like @ is monumentally
stupid.

In a one-namespace language, the application of arguments to a value is
enough to make it a function call. I.e. there is already a calling operator
in "X(...)", namely the postfix (...) part.

Anton Treuenfels

unread,
Apr 24, 2015, 7:23:14 PM4/24/15
to

"Anton Treuenfels" <teamt...@yahoo.com> wrote in message
news:R7adnTLfvtu7z6fI...@earthlink.com...
>
> Given that the above does not work, I suppose it would be even more of a
> nightmare to try to get something like this to work:
>
> ======================
>
> for( i in strndx )
> @i()
>
> =======================

My bad. That actually does work, and if I'd thought about it a little longer
at the time I would have realized it.

> I didn't even try that. But I did make this mistake:
>
> =======================
>
> for ( i in strndx ) {
> myindirect = strndx[ i ]
> @myindirect()
> }
>
> =======================
>
> which, since the contents of each strndx[] is the null string, didn't work
> either. But it did upset gawk enough to "request being shut down in an
> unusual way", according to the message on the screen.

But this doesn't just happen if the function "name" happens to be the null
string. It also happens if there is no function matching whatever name is
used (as I discovered by screwing up). I can see that this error must be
detected at run time instead of parse/compile time, but it still seems to me
that a message along the lines of:

"Indirect call to non-existent function: (name)"

might be a bit more helpful.

- Anton Treuenfels

Aharon Robbins

unread,
Apr 25, 2015, 2:30:43 PM4/25/15
to
In article <R7adnTLfvtu7z6fI...@earthlink.com>,
Anton Treuenfels <teamt...@yahoo.com> wrote:
>BUT the reason I wrote it was to test whether or not the variable holding
>the function name could be an array variable. That is, could I write
>something like this:
>
>=====================
>
> for ( i in numndx )
> @numndx[ i ]()
>
>=====================
>
>The answer is no, I cannot. Syntax errors abound. But that is not something
>I could find out from the documentation - I had to try it.

The documentation says:

The syntax is similar to that of a regular function call: an
identifier immediately followed by an opening parenthesis, any
arguments, and then a closing parenthesis, with the addition of
a leading @samp{@@} character:

That's pretty clear. numndx[i] is an expression, not a single identifier.

>which, since the contents of each strndx[] is the null string, didn't work
>either. But it did upset gawk enough to "request being shut down in an
>unusual way", according to the message on the screen.

On Linux:

$ cat x.awk
BEGIN {
strndx[1]
for ( i in strndx ) {
myindirect = strndx[ i ]
@myindirect()
}
}
$ ./gawk -f x.awk
gawk: x.awk:5: fatal: `' is not a function, so it cannot be called indirectly

I can't help it if Windows does something weird when exit() is called.

Anton Treuenfels

unread,
Apr 27, 2015, 10:16:33 AM4/27/15
to

"Aharon Robbins" <arn...@skeeve.com> wrote in message
news:mhgmel$4u4$1...@dont-email.me...
>
> The documentation says:
>
> The syntax is similar to that of a regular function call: an
> identifier immediately followed by an opening parenthesis, any
> arguments, and then a closing parenthesis, with the addition of
> a leading @samp{@@} character:
>
> That's pretty clear. numndx[i] is an expression, not a single identifier.

Indeed it is, as is any scalar variable when I assign a string to it. But
what the documentation implies is that the same character string is being
used with two different meanings in the same function. Ie.,

{
i = "myfunction" # here 'i' is a variable name
@i() # here 'i' is not a variable name
}

I'm not used to such equivocation. I had imagined that once a variable,
always a variable, which is why I was dismayed to find

{
a[i] = "myfunction"
@a[i]()
}

does not work. It's not difficult to work around, but it may not be quite as
obvious for everyone to grasp as it is for you.

I suppose the way it is being done does avoid such perverse uses as

{
i = "my"
j = "function"
@ij()
}

>>which, since the contents of each strndx[] is the null string, didn't work
>>either. But it did upset gawk enough to "request being shut down in an
>>unusual way", according to the message on the screen.
>
> On Linux:
>
> $ cat x.awk
> BEGIN {
> strndx[1]
> for ( i in strndx ) {
> myindirect = strndx[ i ]
> @myindirect()
> }
> }
> $ ./gawk -f x.awk
> gawk: x.awk:5: fatal: `' is not a function, so it cannot be called
> indirectly
>
> I can't help it if Windows does something weird when exit() is called.

Perhaps. On the other hand, on Win64 there is a difference between
non-existent functions called directly and indirectly.

Called directly gets this message:

# calling a non-existent function directly
# - "fatal: function 'myfunction' not defined"

BEGIN { myfunction() }

Called indirectly gets this message:

# calling a non-existent function indirectly
# - "This application has requested the Runtime to terminate it
# in an unusual way. Please contact the application's support
# team for more information"

BEGIN { i = "myfunction"; @i() }

The fact that a non-existent function called directly triggers a runtime
error suggests to me that there is some sort of name-address mapping going
on that is dynamically examined at runtime. The fact that a non-existent
function called indirectly triggers a complete meltdown suggests to me that
the same mechanism is not being used in that case.

Which is puzzling to me. Being naive, I had imagined that indirect function
calls were implemented simply by retrieving the name from the - well, it's
not actually a variable, but whatever else it might be it is at least a
repositor for a name - and handing that name to whatever mechanism handles
direct calls. That would seem to assure the same response to whatever errors
might occur in connection with a function call.

- Anton Treuenfels

Kaz Kylheku

unread,
Apr 27, 2015, 11:57:38 AM4/27/15
to
On 2015-04-27, Anton Treuenfels <teamt...@yahoo.com> wrote:
>
> "Aharon Robbins" <arn...@skeeve.com> wrote in message
> news:mhgmel$4u4$1...@dont-email.me...
>>
>> The documentation says:
>>
>> The syntax is similar to that of a regular function call: an
>> identifier immediately followed by an opening parenthesis, any
>> arguments, and then a closing parenthesis, with the addition of
>> a leading @samp{@@} character:
>>
>> That's pretty clear. numndx[i] is an expression, not a single identifier.
>
> Indeed it is, as is any scalar variable when I assign a string to it. But
> what the documentation implies is that the same character string is being
> used with two different meanings in the same function. Ie.,
>
> {
> i = "myfunction" # here 'i' is a variable name
> @i() # here 'i' is not a variable name
> }

So Gawk is a "Lisp-2", effectively, and @ is something like its funcall
operator.

The dual-namespace Lisp-2 approach has advantages.

One is that you can name local variables without worrying that they shadow
functions that you might use in the same scope.

The second advantage, related to the first, is that you can have a simple
non-hygienic macros system in which macro expansion assume that standard
functions are not shadowed by anything, and only take care of using
"gensyms" in the variable namespace.

In a Lisp-2 like Common Lisp, if we write a macro which uses standard library
functions in its macro expansion, like list, cons and whatever, the only way
there will be a hygiene problem is if the code uses these as the names of local
functions:

(flet ((list () )) ;; local function named list
(some-macro ...)) ;; oops, macro expansion uses list function!

(let ((list '(a b c))) ;; local variable named list
(some-macro ...)) ;; macro expansion uses list; no problem!

In Lisp-1 dialects, hygienic macros are needed to avoid problems like a
variable called list or cons capturing a function. And of course you cannot use
any function name as a variable, if there is a use of that function in the
variable's scope. So for instance Scheme code is littered with "lst"
instead of "list" as a variable name.

> I'm not used to such equivocation. I had imagined that once a variable,
> always a variable, which is why I was dismayed to find
>
> {
> a[i] = "myfunction"
> @a[i]()
> }
>
> does not work.

You're probably also used to a single namespace for functions and variables in
most of the languages you use.

> Which is puzzling to me. Being naive, I had imagined that indirect function
> calls were implemented simply by retrieving the name from the - well, it's

"indirect function call" is a machine-language concept. A call is direct
if the machine language instruction contains the destination address.
A call is indirect if the machine language instruction calculates the
address using run-time data. (With various in-between possibilities, like
an offset from the instruction, plus run-time data: relative jump,
jump indexed through a table, etc.)

Even the fairly low-level language C doesn't have "indirect call" as a concept:
at least not one that is distinguished in the syntax.

f(x, y) is an indirect call if f is a pointer, otherwise a direct call.
This terminology is not used in ISO C, to my recollection.

The abstract semantics of f(x, y) is that even if f is the name of a function,
it first produces a pointer, and then the arguments are applied to the
function pointer to produce a call.

In any case, no special indirection operator is needed to call the pointer.

(In some very old C sources, you sometimes see pointer calls written
like (*f)(x, y). It might have been needed.)

It's ironic if a high level data munging language (loosely based on C) makes
you use some "splat" to indirect on a function, when the underlying C doesn't
itself have that inconvenience. *facepalm*.

Janis Papanagnou

unread,
Apr 27, 2015, 9:06:46 PM4/27/15
to
On 04/27/15 17:57, Kaz Kylheku wrote:
>
> (In some very old C sources, you sometimes see pointer calls written
> like (*f)(x, y). It might have been needed.)

Why only in "some very old C sources"? - How would nowadays (in C) be
function tables implemented? (Indexed arrays and switch constructs?)

Janis

Kaz Kylheku

unread,
Apr 27, 2015, 9:25:45 PM4/27/15
to
My point is only that, at least in 1989 ANSI C and later, (*f)() means exactly
the same thing as f() if f is a pointer to a function. (As an expression, of
course---not as a declarator.)

(The (*f)() style call has the virtue that it looks like the declarator
for a pointer-to-function. I.e. "declarations follow use" and when they
don't, fix them so they do!)

Now if f is a pointer to a pointer to a function, that is different,
of course! That is double indirection. f is a pointer to a datum which
cannot be called using the expression f(). That is where a non-useless
use of (*f)() comes in.

Aharon Robbins

unread,
Apr 28, 2015, 2:21:44 AM4/28/15
to
In article <H6-dnUeBo9Ui2aPI...@earthlink.com>,
Anton Treuenfels <teamt...@yahoo.com> wrote:
>Called indirectly gets this message:
>
># calling a non-existent function indirectly
># - "This application has requested the Runtime to terminate it
># in an unusual way. Please contact the application's support
># team for more information"
>
>BEGIN { i = "myfunction"; @i() }

$ ./gawk 'BEGIN { i = "myfunction"; @i() }'
gawk: cmd. line:1: fatal: `myfunction' is not a function, so it cannot be called indirectly

Again, I can't help it if Windows does something screwy.

Indirect calls aren't as simple to implement as direct calls, there
is extra stuff to do, particularly if calling builtin functions.

As to syntax, while it would have been possible to not require the @ sign,
I purposely wanted a syntactic difference from a regular function call,
to make it clear that such code is usable only with gawk.
0 new messages