[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a bug or a feature?
From: |
Aharon Robbins |
Subject: |
Re: a bug or a feature? |
Date: |
Tue, 29 Apr 2003 12:06:37 +0300 |
Greetings. Re this:
> Date: Fri, 25 Apr 2003 11:59:25 +0200 (CEST)
> From: Boguslaw Jackowski <address@hidden>
> To: address@hidden
> cc: Martin Berggren <address@hidden>,
> Janusz Marian Nowacki <address@hidden>
> Subject: a bug or a feature?
>
> Dear colleagues,
>
> We've encountered a strange behaviour of gawk which has something
> to do with the `delete' operator. The following three-liner
>
> BEGIN {a(); b(S)}
> function a() {delete S}
> function b(s) {s[0]}
>
> reports an error:
> ... fatal: delete: illegal use of variable `S' as array
>
> This error is reported under both Linux and Windows since the
> version (at least) 3.1.0 (also in 3.1.2).
>
> Apparently, gawk presumes that `S' should be a scalar judging from
> the statement `b(S)'. There is a simple circumvention---it suffices
> to add, e.g., a dummy function definition at the beginning of the script:
>
> function c() {S[0]}
>
> Because of the weirdness of the circumvention, we doubt whether
> this behaviour can be considered a `feature'.
>
> Looking forward to hearing from you --
>
> yours sincerely, Bogus\l{}aw Jackowski, Piotr Strzelczyk
>
> Ps. Due to the optimization efforts in most recent versions
> of gawk, the error is reported also for a `traditional'
> form of using the `delete' operator:
>
> function a() {for (i in S) delete S[i]}
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Bogus\l{}aw Jackowski: address@hidden
> ----------------------------------------------------------------
> Hofstadter's Law: It always takes longer than you expect, even
> when you take into account Hofstadter's Law.
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This area is a bit messy in current gawk. I have fixed things in
my current sources, which will eventually be 3.1.3. For now,
you may use the patch Stepan posted, or use your workaround.
Thanks,
Arnold