[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a bug or a feature?
From: |
Boguslaw Jackowski |
Subject: |
a bug or a feature? |
Date: |
Fri, 25 Apr 2003 11:59:25 +0200 (CEST) |
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.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- a bug or a feature?,
Boguslaw Jackowski <=