Am 05.04.2013 13:25, schrieb Aharon Robbins:
> Hi.
>
> In article <kjmbjs$cef$
1...@speranza.aioe.org>,
> Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
>> It makes no sense in the context of any general function "do_something"
>> (to take the name from your example). But in the context of a specific
>> function (like gensub), a function that supports back-references, it
>> would also make sense that this function would apply a lazy evaluation
>> concept for the replacement expression.
>
> No, not really. Gensub takes a replacement string as the argument
> specifying how to build the result, just like sub and gsub do. Gawk is
> not the shell, nor is it perl, nor does it desire to be either of them.
>
>> This is currently not supported by gawk (and probably never will be),
>
> Right on both.
>
>> but I think it would be possible,
>
> Just because something is possible doesn't mean it's a good idea.
You think - apart from implementation difficulties - it is a bad idea?
Given the application I outlined upthread I have to disagree. YMMV :-)
>
> And in this case, it is actually quite difficult,
Yes, I have thought so. And I did not expect that to get implemented.
The point of my posting was to correct a statement that I originally
agreed to; whether such an operational semantics would make sense or
not.
> since it means runtime
> (re-)evaluation of an expression that has already been parsed.
I am aware that it may not fit well. On the other hand I'd think that
with an intermediate-code interpreter (as present in gawk) it may be
even easier to implement than with a straight compiler.
Given the gawk specific version gensub that already supports non-regular
features like back-references, having another semantic extension in the
context of that function would also not have undesired side-effects; the
effects would anyway be local to a non-standard function.
But okay, I don't want to beat a dead horse.
> It's
> not something I would care to try, since it would VERY badly warp the
> code
Yes, I thought so.
> for something that could be accomplished in a more straightforward
> manner with awk code.
You mean re-looping again and again over subexpressions? - Well... :-/
>
>> it would make sense,
>
> Only in a language with dynamic evaluation everywhere, like lisp, shell,
> perl, or whatever. Not in [g]awk.
It's certainly eassier in those languages, sure.
>
>> and it would be helpful.
>
> I think only marginally so, to be honest; the ROI for the real work
> needed is too low.
>
> Sorry to rain on your parade... :-)
Don't worry :-) As said, I did't mean that to get implemented (even
though I'd have appreciated it ;-). Just wanted to correct my statement.
On a related note, Arnold... - a question I am not sure whether it had
already been mentioned here...
The back-references implementation may require a non-finite automata.
Are there two matching implementations in gawk, one that use the classic
fast matching, and one that use some backtracking for the back-refs,
selected depending on the contents of the actual regexp expression, or
is there only one algorithm implemented?
Janis
>
> Arnold
>