On 2020-01-16 13:09, Richard Hainsworth wrote:
What is in WinReg?
Bear in mind that the top level Raku program is compiled into memory and
run. But the default for any Module is that it is compiled first, and
the compiled version is stored. (You can prevent precompilation by using
the statement "no precompilation;" which can be useful if you want to
have trace statements. But don't forget to take out the 'no
precompilation' once development has finished.)
So the Raku compiler finds all the 'use' statements, and looks for an
already compiled version of some module (lets call it Module) - the
'precompilation'. (Have you noticed any .precomp/ directories in the
directory you run the program from?) There is a reason for this, but
it's a bit long to explain here.
If a precompiled version cannot be found by Raku, then it will compile
the first source of Module and store it in an appropriate place (a local
.precomp/ directory if you are developing Module and you haven't
installed it). That is why when you run a Raku program for the first
time with a big module it takes for ever, but the next time it goes
quite fast.
If there is a 'use' statement in the Module, then Raku will do the same
for that module.
What often happened to me was that I developed a module and I had a "use
lib 'lib';" statement in it. When the module was the top program (so to
speak), no errors arise, but when you try to pre-compile that Module,
you get an error.
The way around this is to delete the 'use lib ...' pragma. And instead,
compile with 'raku -Ilib ...' (or 'perl6 -Ilib'). Note that the option
is Capital I not lower l (the font in my email agent doesn't make it
easy to see the difference).
This option implies that there is a directory 'lib' local to the
directory where the raku compiler is being invoked, and that your module
WinReg.pm6 is in 'lib'. Raku then looks FIRST at 'lib' for Module. If it
finds a source there, it compiles it and stores it. It then does not
look any further for WinReg.pm. For other modules, Raku will then look
along the default linked list of directories until it finds a source it
can use.
Hope this helps a bit.
Richard
Hi Richard,
Thank you for marvelous explanation and tip!
Tobs on the chat line told me what was going on.
Two of my modules were importing each other. So
I took the common code and created another module.
Love modules. I live and die with Top Down and
did a lot of Modula2 programming in a past life.
:-)
-T
Just a comment: I ADORE the way Raku does its modules
and its sub declarations.
Perl 5 use to drive me nuts with passing reference
pointers to subs. The second I saw Larry latest sub declarations, I
dropped Perl 5 like a hot potato.
P5 is good stuff mind you, but P6 is marvelous! It is
one of the reason why I belly ache about the
documentation all the time. I can't inhale Raku
fast enough! I want to write and write and write!