[Top][All Lists]

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

Re: [bug-gawk] optional strict gawk semantics

From: Aharon Robbins
Subject: Re: [bug-gawk] optional strict gawk semantics
Date: Fri, 15 Aug 2014 14:27:37 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi Assaf.

> Date: Thu, 14 Aug 2014 17:02:59 -0400
> From: Assaf Gordon <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] optional strict gawk semantics
> Hello Arnold and all,
> I'd like to ask your opinion about an idea I've been toying around with, 
> regarding gawk.
> I'm looking for a way to make gawk stricter with regards to input
> validation (but preferably doing so 'automatically', ie not adding
> explicit awk code).
> Specifically, I'd like to trigger an error when:
> 1. running numeric operation on a string value (one that can't be converted 
> to a number)
> 2. when accessing a field number which doesn't exist (e.g. "$5" when the 
> input has only 3 columns).
> 3. When accessing an array with a non-existing index
> Do you think such addition is possible in current gawk?

Technically it's possible, you just have to add the checks at the right
places in the code.

> And would you consider such feature for inclusion (enabled with a
> command-line option of course) ?  If so I could try to come up with
> a patch.

The right way to do this is to extend the --lint option with something
like --lint=strict or --lint=validate.

I am concerned though that these checks might impact the runtime since
the cases you name are likely to happen a lot, especially conversion
of non-numeric string to zero.  For at least that operation I'd like
to see the code inside an #ifdef that is disabled by default.  You could
then do some timings on some LARGE but valid datasets to see if the
test has an impact.

I believe you've already signed paperwork with the FSF for gawk, right?
We'll need that in place if you haven't.



reply via email to

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