bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Missing double quotes in SYMTAB example in docs


From: arnold
Subject: Re: [bug-gawk] Missing double quotes in SYMTAB example in docs
Date: Mon, 11 Jul 2016 20:38:39 -0600
User-agent: Heirloom mailx 12.4 7/29/08

A reasonable suggestion. I have just added such an example and will
push it to the repo shortly.

Thanks,

Arnold

Jaromir Obr <address@hidden> wrote:

> OK, it makes sense. Maybe if the example in docs contained call of the
> function, it would be more clear (at least for me :)).
>
> Thanks you very much.
>
> Mira
>
> On Mon, Jul 11, 2016 at 9:39 PM, <address@hidden> wrote:
>
> > Hi.
> >
> > What you want is
> >
> >         multiply("i", 2)
> >
> > Note that the `i' in the multiply function is different from the
> > global `i' assigned to in the BEGIN rule.
> >
> > HTH,
> >
> > Arnold
> >
> > Jaromir Obr <address@hidden> wrote:
> >
> > > Based on the example originally I tested this:
> > >
> > > BEGIN {
> > >         i = 10
> > >         multiply(i, 2)
> > >         print i
> > > }
> > > function multiply(i, amount)
> > > {
> > >     return SYMTAB[i] *= amount
> > > }
> > >
> > > but it didn't work as expected (result is 10 instead 20). Therefore I
> > would
> > > expect SYMTAB["i"].
> > >
> > > Mira
> > >
> > > On Sun, Jul 10, 2016 at 10:25 PM, david kerns <address@hidden>
> > > wrote:
> > >
> > > > if it used less descriptive names, say a and b, would you still say it
> > > > needs double quotes?
> > > >
> > > > # Indirect multiply of any variable by amount, return result
> > > >
> > > > function multiply(a, b)
> > > > {
> > > >     return SYMTAB[a] *= b
> > > > }
> > > >
> > > >
> > > > On Sun, Jul 10, 2016 at 10:24 AM, Jaromir Obr <address@hidden>
> > > > wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> in
> > > >>
> > https://www.gnu.org/software/gawk/manual/gawk.html#index-differences-in-awk-and-gawk_002c-SYMTAB-variable
> > > >> there is an example:
> > > >>
> > > >> # Indirect multiply of any variable by amount, return result
> > > >>
> > > >> function multiply(variable, amount)
> > > >> {
> > > >>     return SYMTAB[variable] *= amount
> > > >> }
> > > >>
> > > >>
> > > >> There are missing double quotes around variable, aren't they ?
> > (expected
> > > >> is return SYMTAB["variable"] *= amount
> > > >>
> > > >> Regards
> > > >>
> > > >> Jaromir
> > > >>
> > > >
> > > >
> >
> >




reply via email to

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