[Top][All Lists]

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

Re: [bug-gawk] 2 questions

From: Denis Shirokov
Subject: Re: [bug-gawk] 2 questions
Date: Mon, 5 Nov 2012 19:09:14 +0200

*get astonished - it's just amazing!

But before doing that i also should do:

if ( isarray(p2) )

- together it will be 3-length-if checking that p2 is not present as
the parameter

Actually total parameter list counter will be much more effective. i
want to implement that feature in own gawk-source parser.

Why gawk documentation at
http://www.gnu.org/software/gawk/manual/gawk.html haven't any words
about possibility of using local arrays in function body?

print b " : " A[""]

func abc(b, A) {
        if ( ++b>3 ) return
        print b " : " A[""]

>gawk -f r.gwk
3 : 3
2 : 2
1 : 1

Function abc() calls itself recursively one time. The first time
(abc-1) - it isn't change array A from the BEGIN-area, and the second
time (abc-2) it isn't change array A from BEGIN-area and array A from
abc-1. Each function call we've got local array A . I use this
everywhere in my code and this is very important feature. It's really
work and i can't understand why in official documentation have no
words about it.

2012/11/5, address@hidden <address@hidden>:
> Hello.
> Denis Shirokov <address@hidden> wrote:
>> Is there a way to request some useful feature in gawk? It's about
>> special array which will accessible  in function body. It should be
>> autodefined from 1 to n - and contain all input parameters given
>> function when its calling from somewhere. for example:
>> abc(10,11)
>> func abc(p0,p1,p2) {
>> # ARRAY[1]==10; ARRAY[2]==11; !(3 in ARRAY) - 3 not present in ARRAY
>> because only 2 parameters given
>> # ARRAY[0]==2 (two parameters given)
>> # ARRAY[""]=="abc" (function name itself)
> I can understand why you might want this, but I don't think that it is
> generally useful.  You can use
>       if (p2 == "" && p2 == 0)
> to konw that p2 is undefined.
> Arnold

reply via email to

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