Re: Circular loading?

2020-01-16 Thread ToddAndMargo via perl6-users

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!


Re: Circular loading?

2020-01-16 Thread ToddAndMargo via perl6-users

On 2020-01-16 13:03, ToddAndMargo via perl6-users wrote:

On 2020-01-16 12:15, ToddAndMargo via perl6-users wrote:

$ raku -I. --stagestats -c WinMessageBox.pm6
Stage start  :   0.000
Stage parse  : ===SORRY!===
Circular module loading detected trying to precompile 
/home/CDs/Windows/NtUtil/WinReg.pm6



Ah Ha!   WinReg called a sub from WinMessageBox

So that is what that message means!

So I will just have to create another module.  Chuckle
I love modules!



Joy!!

$ raku -I. --stagestats -c WinMessageBox.pm6
Stage start  :   0.000
Stage parse  :   1.296
Stage syntaxcheck: Syntax OK

$ raku -I. --stagestats -c WinReg.pm6
Stage start  :   0.000
Stage parse  :   2.132
Stage syntaxcheck: Syntax OK

$ raku -I. --stagestats -c NativeConvert.pm6
Stage start  :   0.000
Stage parse  :   0.424
Stage syntaxcheck: Syntax OK


Re: Circular loading?

2020-01-16 Thread Richard Hainsworth

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

On 16/01/2020 20:15, ToddAndMargo via perl6-users wrote:

On 2020-01-16 11:45, ToddAndMargo via perl6-users wrote:

Hi All,

How do you troubleshoot:

  raku -I. -c WinMessageBox.pm6

  Circular module loading detected trying to
  precompile /home/CDs/Windows/NtUtil/WinReg.pm6

I have traced it down to this:


 use WinReg :to-UTF16-c-str;
or just
 use WinReg;


Comment it out and it checks fine.  I am not calling
any modules imported from WinReg.pm6 at this point.

What is going on?

Yours in confusion,
-T


Does this help?

$ raku -I. --stagestats -c WinMessageBox.pm6
Stage start  :   0.000
Stage parse  : ===SORRY!===
Circular module loading detected trying to precompile 
/home/CDs/Windows/NtUtil/WinReg.pm6


Re: Circular loading?

2020-01-16 Thread ToddAndMargo via perl6-users

On 2020-01-16 12:15, ToddAndMargo via perl6-users wrote:

$ raku -I. --stagestats -c WinMessageBox.pm6
Stage start  :   0.000
Stage parse  : ===SORRY!===
Circular module loading detected trying to precompile 
/home/CDs/Windows/NtUtil/WinReg.pm6



Ah Ha!   WinReg called a sub from WinMessageBox

So that is what that message means!

So I will just have to create another module.  Chuckle
I love modules!


Re: Circular loading?

2020-01-16 Thread ToddAndMargo via perl6-users

On 2020-01-16 11:45, ToddAndMargo via perl6-users wrote:

Hi All,

How do you troubleshoot:

  raku -I. -c WinMessageBox.pm6

  Circular module loading detected trying to
  precompile /home/CDs/Windows/NtUtil/WinReg.pm6

I have traced it down to this:


     use WinReg :to-UTF16-c-str;
or just
     use WinReg;


Comment it out and it checks fine.  I am not calling
any modules imported from WinReg.pm6 at this point.

What is going on?

Yours in confusion,
-T


Does this help?

$ raku -I. --stagestats -c WinMessageBox.pm6
Stage start  :   0.000
Stage parse  : ===SORRY!===
Circular module loading detected trying to precompile 
/home/CDs/Windows/NtUtil/WinReg.pm6


Circular loading?

2020-01-16 Thread ToddAndMargo via perl6-users

Hi All,

How do you troubleshoot:

 raku -I. -c WinMessageBox.pm6

 Circular module loading detected trying to
 precompile /home/CDs/Windows/NtUtil/WinReg.pm6

I have traced it down to this:


use WinReg :to-UTF16-c-str;
or just
use WinReg;


Comment it out and it checks fine.  I am not calling
any modules imported from WinReg.pm6 at this point.

What is going on?

Yours in confusion,
-T