bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] gawk 5.0.1 patch to allow *valid* awk variable names to b


From: pjfarley3
Subject: Re: [bug-gawk] gawk 5.0.1 patch to allow *valid* awk variable names to be assigned to SYMTAB
Date: Mon, 21 Oct 2019 20:06:51 -0400

Hi Andy,

I did look at the gawkextlib project code base for csv, but that seems a bit
beyond what I need on a more immediate basis.  I like what I saw, but for
the moment I would like to try something simpler.

(P.S. -- Is Manuel no longer working on that csv project?  I remember him
from too many years ago when we both were active on the DJGPP project.)

Back to this subject.  Is it possible to simply introduce a new C source
program into the gawk/extensions sub-directory and somehow just use a make
of gawk itself to find and compile and bind the new program into the
extensions library?

I am assuming here that I will be able to craft a new C source from the
existing models in the gawk/extensions sub-directory fairly quickly for the
simple function(s) I envision at the moment.

If so, what additional files besides the C source itself need to be
updated/created in the gawk/extensions sub-directory to allow this to happen
seamlessly?  Also, how does one go about adding tests for new C source
function(s)?

Apologies for my vast ignorance here, but I am trying to learn as I go
along.

Peter

> -----Original Message-----
> From: Andrew J. Schorr <address@hidden>
> Sent: Monday, October 21, 2019 7:25 AM
> To: address@hidden
> Cc: address@hidden; address@hidden
> Subject: Re: [bug-gawk] gawk 5.0.1 patch to allow *valid* awk variable
names
> to be assigned to SYMTAB
> 
> Hi,
> 
> A few points:
> 
> 1. Tom's suggestion involves more typing than necessary. The example
below:
>       FNR == 1 { for (i = 1; i <= NF; i++) mem[$i] = i }
>       $(mem["Name"]) ~ /^H/ { process H.* records }
>       $(mem("Amount"]) < 0 { process negative amount records }
> 
> can be rewritten as (and I use this approach all the time):
>    NR == 1 {
>       for (i = 1; i <= NF; i++)
>        m[$i] = i
>       next
>    }
> 
>    $m["Name"] ~ /^H/ { process H.* records }
>    $m["Amount"] < 0 { process negative amount records }
> 
> This saves 4 characters per variable reference (mem -> m, and no need for
the
> parentheses), so reduces the overhead by almost 50% (9 -> 5). :-)
> 
> So yeah, it costs you a bit of typing, but it's so much cleaner than
mucking with
> SYMTAB.
> 
> 2. If the goal here is really to process CSV files, then there's a
gawkextlib project
> to develop a CSV processing extension that could probably benefit from
some
> development/contributions.
> 
> 3. If you develop your own extension, you are welcome to contribute it to
the
> gawkextlib project.
>    http://gawkextlib.sourceforge.net/
>    https://sourceforge.net/projects/gawkextlib/
> 
> Regards,
> Andy
> 
> On Mon, Oct 21, 2019 at 01:50:32AM -0400, address@hidden wrote:
> > Apologies for forgetting to CC the list for the last two iterations of
> > this discussion.  I am correcting that mistake with this reply.
> >
> > Arnold,
> >
> > I understand your lack of enthusiasm, particularly after seeing the
> > unexpected and undesired results when I tried to actually use my
> > proposed update.
> >
> > After having reviewed the manual documentation of the gawk extension
> > API, I tend to agree that what I want to do is most easily done in a
> > new extension function.
> >
> > There do appear to be several of the delivered extension function
> > sources I could use as a model for a relatively simple extension
> > function that satisfies my use case.
> >
> > Thank you for your understanding, guidance, and genuine consideration
> > of my needs.
> >
> > If I get such an extension operating correctly and robustly, is there
> > any interest in my contributing that extension to the project?
> >
> > Regards,
> >
> > Peter
<Snipped> 
> --
> Andrew Schorr
--




reply via email to

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