Re: Help with %?RESOURCES variable

[email protected] (Polgár Márton)
Newsgroups perl.perl6.users
Message-ID <VI1P195MB0014182A25D2DA6648B8313FFE629@VI1P195MB0014.EURP195.PROD.OUTLOOK.COM>
I mean, yes... the program runs at runtime. Anything available to the 
program is "available during runtime". Yes, you can look up the content 
at runtime - e.g from the place where it's installed. It is NOT advised 
to try and change the content that you can look up with %?RESOURCES - 
you aren't even supposed to know where it is; but as static data, you 
can always access it during runtime.

Regardless, what Brad Gilbert says seems to be consistent with what I 
can recall from a couple of months ago: it is only set in *modules* of a 
distribution. It can be set even if the module isn't precompiled but 
either way - it's not set in a mere raku script, even if it is located 
under the root folder of a distribution.

On 2023. 04. 19. 21:54, yary wrote:
> https://docs.raku.org/language/variables says
>
>     |%?RESOURCES|is a compile-time variable available to the code of
>     aDistribution <https://docs.raku.org/type/Distribution.html>.
>
>     It contains a hash that provides compile and runtime access to
>     files associated with the Distribution of the current compilation
>     unit.
>
>
>  The intent of that reads as - the value is set during compilation, 
> and is available during runtime. Seems like either the doc is wrong, 
> or the implementation is incomplete. I'm hoping that the doc is right, 
> because it's useful to be able to read %?RESOURCES during runtime, and 
> in general useful to set a variable once during compile, then read it 
> forever at runtime.
>
> -y
>
>
> On Wed, Apr 19, 2023 at 3:00 PM Brad Gilbert <[email protected]> wrote:
>
>     Unless things have changed since I was last active, only modules
>     are precompiled. `?` Twigilled variables are set at compile time.
>     So if it had any values, they wouldn't be useful, because they
>     would be created anew every time.
>
>     On Mon, Apr 17, 2023, 11:48 AM David Santiago <[email protected]>
>     wrote:
>
>
>         Hi Polgár
>
>         A seg, 17-04-2023 às 18:08 +0200, Polgár Márton escreveu:
>         > I think this is the classic case of ?-twigilled, "compile-time"
>         > variables only being available in modules. It kind of forces
>         you to
>         > always have the pattern of: heavy-lifting in a module inside
>         lib, and
>         > the script just uses the module.
>         >
>
>
>
>         yes, that was the case. It works inside a module. I guess i
>         have to
>         think differently on how to organize the code.
>
>         Thanks and best regards,
>         David Santiago
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.