[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: built-in functions are missed in non-awk namespaces
From: |
arnold |
Subject: |
Re: built-in functions are missed in non-awk namespaces |
Date: |
Thu, 01 Aug 2024 06:39:27 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
If having spaces in the filename still works, you have
a strange system.
The next major release of gawk will likely have @nsinclude which
will include a file but keep it in the current namespace. Such
files will be allowed to be included more than once. That will
solve the problem.
Arnold
Denis Shirokov <cosmogen@gmail.com> wrote:
> ...regarding whether @include would preserve the current namespace:
>
> Just had a thought: what if in each namespace we do an Include with a
> description of some basic functions, needed just for general operation.
> Something like
>
> func _a( a,b,c,d ) {
> return a }
>
> func _b( a,b,c,d ) {
> return b }
>
> func _print( t ) {
> print t :}
>
> and so on ...
>
> Turns out, it won't work. You can only include a file once. Wait a minute!
> What if we add a space to the name of the included file? Wow! Its works.
> But how am I supposed to know how many spaces to add? .. Hmm. I think each
> library should have its own number of spaces when a file @including
>
> Forgive me, that's just my sense of humor :)
>
> with Respect
> Denis)
>
> вт, 30 июл. 2024 г. в 19:43, <arnold@skeeve.com>:
>
> > Denis Shirokov <cosmogen@gmail.com> wrote:
> >
> > > 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?
> >
> > It is documented, see
> > https://www.gnu.org/software/gawk/manual/gawk.html#Changing-The-Namespace.
> >
> > > Right now, I see that it is always awk namespace at the beginin of fuke
> > > included. Is this correct?
> >
> > Yes.
> >
> > > Perhaps it would be more convenient if the namespace remained current -
> > > the one from which the @include itself was made.
> >
> > This has it's advantages and disadvantages. The main disadvantage is
> > that making this change would break existing programs. It might have
> > been better to do things the other way, but it's too late now. :-(
> >
> > Thanks,
> >
> > Arnold
> >