help-gawk
[Top][All Lists]
Advanced

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

Re: @include suggesting feature: PROCINFO[ "include" ] array


From: Denis Shirokov
Subject: Re: @include suggesting feature: PROCINFO[ "include" ] array
Date: Wed, 16 Mar 2022 07:01:54 +0200

hi Gawk Team!

some months ago i was sending here some of the @include directive
suggested features - and i want to pay your attention again about one
small feature that i was suggesting:

all files that was @included as the part of the gawk's script source
are present in the predefined global array PROCINFO[ "include" ] for
each file included:

        @include "abc.gwk"
        # PROCINFO[ "include" ][ "abc" ] = "filepath/" abc.gwk

this feature is able to know  at the user level the exact filepath of
itself code.
at this moment i may provide at least two examples because of why this
feature is really needfull:

1) as i said previously: an library may needs some files during i's
initialization. and this file should be placed near with the file
@included. and there is no possibility to read that kind of files
because we don't know WHERE required file is located.
as example of such kind files i was reporting exact mylife-cases:
- library for generating graphic files was needs the default.bmp and
default palette files
- an text-macro service library was requring to load auto macro definition file

2) now there is another case why this feature will be really helpful:
- one of my gawk library have self-modification feature: it's reading
ITSELF FILE and compares it with the stored copy of itself file that
is placed NEAR ITSELF FILE.  if files are not equal to each other then
copy of the file is refreshed and self-modification process performed
generating new version of itself file.

after rewriting library-itself file by generated new itself-version
gawk's execution will be aborted because of requiring gawk script
restart.
the self-modification feature is allows to quckly operates with the
library's constant values.

in fact without this feature an multiple hardcoded filepaths are
using. this leads to fact that gawk script by default never can be
portable or have multiplatform support (the cases that i having in my
job)
the suggested feature is small, safe and strong.
may its have a chance just to be discussed by the Gawk Team? =)

note: possibly Dynamic Extensions may also needs in such like feature

with Respect
Denis


2022-01-07 21:41 GMT+02:00, Denis Shirokov <cosmogen@gmail.com>:
> hello Gawk Team
>
> i'm just voicing my thoughts about the include directive features
> thats may be useful for gawk's user:
>
> it's will be nice if gawk script may gets full filepath of the every
> files that was @included
>
> like if PROCINFO[ "include" ] is the predefined subarray containing as
> the indexes full filepaths of the all files included.
>
> some of my libraries needs to load and process some files during
> initialization.
>
> the files are logically located at the same location as the file
> included. this will lead to problems with runing my scripts from
> non-hardcoded locations.
>
> if such kind include-file list will be provided by gawk the library's
> initializations may find itself in this list and then just get
> location of the file required
>
> and it is possible that dynamic extensions also may needs such kind
> feature.
>
>
> also:
>
> it's will be very useful and whats more important - more correct if
> for @include directives located in a file the current directory will
> be directory from where file was been loaded - not the user's current
> folder as it's currently in gawk.
>
> many of my include files contains nested subincludes that should
> loaded exactly from where original include file was get.
>
> also:
>
> it's will be nice if @include directive may support access to
> environment variables like it's realized in batch files:
>
> @include "%AWKPATH%/arr/arr.inc"
>
>
> Best Regards
> Denis
>



reply via email to

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