bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] in-place edit request


From: Ed Morton
Subject: Re: [bug-gawk] in-place edit request
Date: Mon, 31 Dec 2012 15:06:51 -0600
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0

Arnold - I get the whole "extensions are easier" to develop angle. I don't understand why code being developed for extension "X" requires that it be invoked as "-i extension_X" rather than allowing gawk to just take an optional "-X" argument but that's fine, I don't need to know. I wouldn't bother with writing a wrapper as having to remember to use "awki" or similar for inplace editing is no better than having to remember to use "awk -i inplace". It's like getting in a car and finding the steering wheels been replaced with something else - whether that something else is a joy stick or a mouse doesn't really matter, it's still MUCH better than nothing even though you'd probably prefer a steering wheel!

Hmm, I suppose there's another scenario here - you currently have a suggestion 
of:

    gawk - the awk interpreter
    awki - a wrapper that calls gawk -i inplace

What if you renamed/reworked them to

    gawk_main - the awk interpreter
gawk - a wrapper that calls gawk_main after expanding single-char extension args. I.e. in shell-ish pseudo-code:
        IF ("-i" is present )THEN
            args = $args "-i inplace"
        ENDIF
        IF ("-f" is present) THEN
            args = $args "-i foobar"
        ENDIF
        ...
        gawk_main $args "$@"

If you had that then "gawk" could use extensions without requiring that the main code be altered (as today) but any new extension functionality that deserved it's own single-character argument ("-i" for inplace and "-f" for foobar above) could get it with just a tweak to the wrapper.

It's just a thought. Whatever.....

I am disappointed that the awk interface for inplace editing will be more cumbersome and unnatural than the sed, perl, and ruby equivalents since I generally feel that awk is a much superior tool for text manipulation but i really do appreciate the effort all of you put into gawk and I do understand that sometimes you have to compromise.

Thanks,

    Ed.

On 12/31/2012 2:18 PM, Aharon Robbins wrote:
Hello Ed.

Ed:
I have a feeling this is [not] going to go down well but here goes: can we
change the existing un-released code to use some other letter for
extension functionality from "-i" to some other letter (I was going
to suggest the obvious "e" or "E" but I see they're already taken so
how about -x for eXtension?) and then use "-i" for "inplace"?
No.

Andy:
I don't actually agree with you about that.  Currently, "-i" tells
gawk to "include" a source code file.  And "-l" tells it to load
a shared library extension.
There are two new features in the development branch ("master" in the
git repo).  -i means read an awk source file. It differs somewhat from -f,
and you can see the details in the gawk manual in that branch.

The -l option means load an extension. You can think of an extension as
being like a plugin in a browser - it's *binary* code loaded into the
gawk address space. Gawk is able to call into the extension and the
extension into gawk, using a defined C API.

The new features work best when used hand-in-hand.  The manual has
some examples, and Andy's gawkextlib project on sourceforge (nee "xgawk")
provides the XML features as a combination of binary extensions and
awk library files.  What's important is that the XML features require
no changes at all to the gawk main code base, whereas previously xgawk
was an actual fork of the gawk code.

These are fairly intuitive option names
that have been used for years by the xgawk approach.  But I'll grant
that the installed base of code is pretty small, so if the community
thinks -i is better used for in-place, then so be it.
*I* don't think that -i is better for in-place, and in this instance,
I have the deciding vote.  Sorry to be heavy handed about it, but
this discussion needs to come to a close.

That being said, there is still not a consensus that the in-place feature
should be added to the main gawk binary.  There is no real point in
debating what option letter should be used for the feature unless we
first agree that the main binary needs to support in-place editing.
This is decided. I will not add it to the main gawk binary because it will
be a ton of code churn (spelled P-A-I-N) for ROI that can be achieved
in easier ways.

Given that this feature can be implemented in an extension, I think
there's a natural reluctance to incorporate it into the main gawk codebase.
Exactly. Since an extension, *considerably more easily*, can provide the
functionality, I am not going to make any changes to the mainline code base.
Period.

I can't find it now, but I believe, Ed, that you stated that you didn't
understand the difference between putting an in-place feature into the
main code base or doing it as an extension.  Fair enough, but since that
is the case, you have to trust me when I say that there is a significant
difference, and that it really does matter.

And you asked, are we talking about shipping a wrapper script with
gawk to run 'gawk -i inplace script files...'.  The answer there is
yes; if someone writes the C extension, the awk files to go with it,
the wrapper script and the documentation (and signs the paperwork if
s/he hasn't done so already), I'll include everything in the dist.

The gawk manual in the master branch explains how to write an extension;
the chapter on it is close to 50 pages, including examples.  The bug-gawk
list archive contains enough discussion so that anyone with medium
C and Unix skills could write the extension, the awk files, and the
shell script.

Now someone in the community, who thinks this feature is worthwhile,
needs to step up to the plate and do the work.

Thanks,

Arnold





reply via email to

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