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

gawk feature request: array assignment

25 views
Skip to first unread message

Charles Obler

unread,
Apr 9, 2009, 2:46:29 PM4/9/09
to bug-...@gnu.org

Hello awk people --

It would be very nice to be able to assign and return arrays. Currently, when I attempt this, I get a fatal "attempt to use array in a scalar context" error message.

I'm attempting to make my awk program somewhat "object-oriented", with associative arrays taking the place of "objects" or "classes". Unfortunately, when I try to return or store one of these "objects", awk complains.

E.g.:

vNaEl = ObjName( vName, vType, vStat) # create a name object
vNASu++ # incr array subscripb
vNArr[ vNASu] = vNaEl # save the object in the objects array

The third statement kills awk.



Aharon Robbins

unread,
Apr 11, 2009, 3:05:09 PM4/11/09
to joyins...@yahoo.com, bug-gn...@gnu.org
Hi.

Thank you for your mail.

While I agree that it would be nice if arrays were true first class
elements of the language, this is not likely to happen, for two
reasons.

1. It would be a very significant departure from historical practice
and the awk language as standardized by POSIX.

2. The current gawk code base is not really up to supporting this.

Thanks,

Arnold

> Date: Thu, 9 Apr 2009 11:46:29 -0700 (PDT)
> From: Charles Obler <joyins...@yahoo.com>
> Subject: gawk feature request: array assignment
> To: bug-...@gnu.org

0 new messages