[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: built-in functions are missed in non-awk namespaces
From: |
Denis Shirokov |
Subject: |
Re: built-in functions are missed in non-awk namespaces |
Date: |
Tue, 30 Jul 2024 19:03:38 +0300 |
One more question - I don’t see any information about this in the
documentation:
What is the initial namespace inside a file when it is @include - the
current one (the one from which the @include was made) or always awk?
Right now, I see that it is always awk namespace at the beginin of fuke
included. Is this correct?
Perhaps it would be more convenient if the namespace remained current -
the one from which the @include itself was made.
kind regards
Denis
вт, 30 июл. 2024 г. в 18:55, Denis Shirokov <cosmogen@gmail.com>:
> Arnold:
> You can even write a library file of such and simply @include it
> where needed.
>
> Yes, that's exactly what I'm doing. But you can't redirect access to
> arrays and variables by this way. In any case, it's not that big of a
> problem as I see it now. Actually, there are very few references to awk-awk
> namespace.
>
> however the namespace feature is a good thing. now i see it. when using
> namespace libraries become truly independent. The interesting thing is that
> at the moment, I have some libraries working in both modes. The old part -
> that works only in the awk namespace. And simultaneously, the updated
> version of the same library that is working using namespace feature. and
> the new libraries internally looks great !
>
> it's Fun) A good thing.
>
> вт, 30 июл. 2024 г. в 18:41, Denis Shirokov <cosmogen@gmail.com>:
>
>>
>>
>>
>> "Outside the awk namespace, the names of the additional gawk built-in
>>> functions (such as gensub() or strftime()) may be used as component names.
>>> The same set of names may be used as namespace names, although this has the
>>> potential to be confusing."
>>>
>>> This is more than I can handle. Are you serious? You're afraid of a
>>> conflict with the functions and() or or()!?
>>>
>>> These are basic built-in functions that have been part of the language
>>> for a very long time, and you're worried that someone will declare a
>>> function and() differently than it's described in AWK?
>>>
>>> This is just ridiculous. I'm serious. And funny. I just can't believe
>>> it. Over the years of using this language, I've gotten used to all sorts of
>>> things and seen strange decisions, some of which I came to appreciate long
>>> after they appeared—I admit. But this?
>>>
>>> I just don't know what to say about this. It's a VERY strange decision :)
>>>
>>> I can explain why I'm so surprised. The thing is, namespace capabilities
>>> appeared relatively recently. If I'm not mistaken, they came with gawk 5+.
>>> So how can name conflicts arise if we're not talking about compatibility
>>> with some old code that users might start running on gawk 5+?
>>>
>>> Old code will run in the main namespace as it should, and if we're
>>> talking about new code that users wrote after the appearance of
>>> namespaces—how would it even occur to them to name some functions with
>>> names that have long been part of the language? What reason could there be
>>> to allow users to declare such functions in a separate namespace?
>>>
>>> Why is patsplit worse than split?
>>>
>>> Because the patsplit appeared later than split? But it appeared earlier
>>> than namespace capabilities—just like Typeof(). Then why don't I understand?
>>> thanx
>>> Denis
>>>
>>>
>>>
>>> пн, 29 июл. 2024 г. в 19:08, Andrew J. Schorr <
>>> aschorr@telemetry-investments.com>:
>>>
>>>> On Mon, Jul 29, 2024 at 11:49:16AM -0400, Andrew J. Schorr wrote:
>>>> > I can't readily find a list of such functions in the manual, but I
>>>> think this
>>>> > hack may work:
>>>>
>>>> Oops, I do now see a list here:
>>>>
>>>>
>>>> https://www.gnu.org/software/gawk/manual/html_node/POSIX_002fGNU.html#:~:text=Additional%20functions%20only,awk%20Programs
>>>> )
>>>>
>>>> But I fear it's missing a few.
>>>>
>>>> Regards,
>>>> Andy
>>>>
>>>
Re: built-in functions are missed in non-awk namespaces, arnold, 2024/07/29