bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: do_lint `delete`


From: Aharon Robbins
Subject: Re: do_lint `delete`
Date: Tue, 16 Jul 2002 16:15:01 +0300

> > > `delete foo[iggy]' should probably be caught by --lint
> > > (line 528 of awkgram.y)
> > >
> > > %>gawk --lint 'BEGIN { delete array; }'
> > > dgawk: cmd. line:1: warning: `delete array' is a gawk extension
> > > %>gawk --lint 'BEGIN { delete array[1]; }'
> > > %>
> >
> > What is the error that --lint should catch? It is not an error to delete
> > an element that isn't there.  If you think it ought to be a warning,
> > there might be room to discuss that.
> >
> > Arnold
>
> i'm not adamant about this, i just figured it should generate the same
> warning.

It should generate a "1 is not an element in array" warning, not that
it's an extension, but that's just a quibble.  What's strange is that
there is a piece of code alreay in place that checks exactly for this
and is supposed to print a lint message.  I'll have to see why it's
not working.  Hmm. I think it's because the variable hasn't been
used as an array before:

        $ gawk --lint 'BEGIN { a[1] = 2 ; delete a[2] }'
        gawk: cmd. line:1: warning: delete: index `2' not in array `a'

Yep, that's it.  I'll try to fix the code and post a patch so that
your case also generates a warning.

> on another note, what is the prominent gawk author's thoughts on 'true'
> multi-dimensional arrays.  I'm interested both in (g)awk philosophy and
> technically (what would it take to implement)?

"Prominent"?  Tee here.  You're not famous if you can go grocery shopping
without hordes of teenage girls throwing themselves at you. :-)

Technically, getting true multidimensional arrays to work in gawk would
probably be painful.  It also introduces very real portability and
standards-compliance issues.  I'm not terribly interested in trying,
since I've (about) hit the limit on the kinds of things I want to
continue trying to shoehorn into gawk.

(This is not to say it wouldn't be nice to have, just that it's too late
both language-wise and implementation-wise to do this.)

Thanks,

Arnold



reply via email to

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