[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gensub() indirectly called with more than 2 parameters: produce a st
From: |
arnold |
Subject: |
Re: gensub() indirectly called with more than 2 parameters: produce a strange error |
Date: |
Wed, 22 Jan 2025 09:31:56 -0700 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Denis Shirokov <cosmogen@gmail.com> wrote:
> i can somewhat understand why sub() and gsub() might be limited during
> indirect calling (since they modify the contents of variables without an
> assignment operation),
That's correct.
> but I absolutely don’t understand why gensub() falls
> under the same criteria. I see no logical connection.
As I just wrote, it was a bug. I included the patch and I have already
pushed the fix to Git.
> The same issue came up in a recent discussion about the behavior of the
> length() function:
> Why does length(A) make A unassigned instead of leaving it untyped?
> Tradition? Guilty!
Yes, I cannot break old programs.
By introducing, starting from gawk 5.2.2 (according to
> the documentation), the ability for array elements to *exist* in an array
> while remaining untyped, you blatantly break compatibility rules. For
> example, when copying one array into another, old code will most likely
> recreate the untyped elements in the target array as unassigned. You’re not
> afraid to break tradition and compatibility there, but when it comes to
> length(), you refer to some kind of tradition...
If you're talking about subarrays, only gawk supports them. It is very
difficult having untyped array elements that can be turned into (sub)arrays
via function calls. Sometimes there are bugs and/or grey areas, and
that's the way it is.
As always, you are welcome to pursue a language that might suit you
better, such as perl or ruby.
Arnold