Re: Problem defining factorial operator in .rakumod file

2022-10-13 Thread Ralph Mellor
On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik  wrote:
>
> I am trying to define '!' as the factorial operator. The following works
> in a .raku script file:
>
>sub postfix: ($n) is export {
>  when $n == 0 {return 1}
>  default {$n * ($n - 1)!}
>}
>
> However when I tried to move this sub to a .rakumod file,
> it produces an error: Negation metaoperator not followed
> by valid infix.

That's because Raku isn't picking up your `sub`.

I don't know why. It works for me. (v2022.02)

Are you sure you're `use`ing it correctly and the `sub`
has the `is export`?

Can anyone else reproduce Joseph's problem?

> It turns out that this is a known issue, #3774

No, that's specific to the REPL.

The error message is the same; the common thing between
the two cases is that Raku is unaware the postfix has been
defined. The REPL problem is known. But the problem you're
sharing is unrelated to the REPL problem.

--
love, raiph


Re: Problem defining factorial operator in .rakumod file

2022-10-13 Thread Joseph Polanik



On 10/13/22 9:19 PM, Ralph Mellor wrote:

On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik  wrote:

I am trying to define '!' as the factorial operator. The following works
in a .raku script file:

sub postfix: ($n) is export {
  when $n == 0 {return 1}
  default {$n * ($n - 1)!}
}

However when I tried to move this sub to a .rakumod file,
it produces an error: Negation metaoperator not followed
by valid infix.

That's because Raku isn't picking up your `sub`.

I don't know why. It works for me. (v2022.02)

Are you sure you're `use`ing it correctly and the `sub`
has the `is export`?


Yes, the sub that defines the factorial operator is marked with 'is 
export' and the script that invokes my module (SequenceHelper) has a 
'use' statement.


The script is able to invoke other methods marked 'is export'; for 
example, the simple ver() and a method that generates an integer sequence:


  sub genSeq_IndexOps($limit, $f) is export {
    my @a = ();
    for (0...^$limit) -> $n {
  @a.push($f($n));
    }
    return @a;
  }

So the module is being found and used. It seems as if certain methods 
aren't being found.


I am not convinced that the problem I'm having is unrelated to the issue 
raised concerning the REPL. When I use the REPL, the results are the same.


[0] > use SequenceHelper;
Nil
[1] > say ver();
v0.0.1
[1] > say 4!;
===SORRY!=== Error while compiling:
Negation metaoperator not followed by valid infix
[1] > put genSeq_IndexOps(15, -> $x {3**$x + 5**$x + 6**$x});
3 14 70 368 2002 11144 63010 360248 2076802 12050504 70290850 411802328 
2421454402 14282991464 84472462690


Regards,

Joe



Re: Problem defining factorial operator in .rakumod file

2022-10-13 Thread Ralph Mellor
On Fri, Oct 14, 2022 at 4:30 AM Joseph Polanik  wrote:
>
> > It works for me. (v2022.02)
>
> When I use the REPL, the results are the same.

The results are the same for ALL of us, for ALL Rakudo versions.
Try the program 42!; Note how the error message is the same.
The results are the same for ALL of us, for ALL Rakudo versions.

Your scenario does not involve the REPL. And it does not occur on
the Rakudo versions I've tried it on even though those versions do
have the REPL bug.

Your scenario is different. Same symptoms. Different root cause.

--
love, raiph


Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen
I cannot reproduce:

% cat lib/A.rakumod 
sub postfix: ($n) is export {
when $n == 0 {return 1}
default {$n * ($n - 1)!}
}
% raku -e 'use lib "lib"; use A; say 42!'
14050061177528798985431426062445115699363840
% raku -v
Welcome to Rakudo™ v2022.07-64-gce1af0fa0.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.07-16-g3ae8a31c1.

> On 14 Oct 2022, at 05:30, Joseph Polanik  wrote:
> 
> 
> On 10/13/22 9:19 PM, Ralph Mellor wrote:
>> On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik  wrote:
>>> I am trying to define '!' as the factorial operator. The following works
>>> in a .raku script file:
>>> 
>>>sub postfix: ($n) is export {
>>>  when $n == 0 {return 1}
>>>  default {$n * ($n - 1)!}
>>>}
>>> 
>>> However when I tried to move this sub to a .rakumod file,
>>> it produces an error: Negation metaoperator not followed
>>> by valid infix.
>> That's because Raku isn't picking up your `sub`.
>> 
>> I don't know why. It works for me. (v2022.02)
>> 
>> Are you sure you're `use`ing it correctly and the `sub`
>> has the `is export`?
> 
> Yes, the sub that defines the factorial operator is marked with 'is export' 
> and the script that invokes my module (SequenceHelper) has a 'use' statement.
> 
> The script is able to invoke other methods marked 'is export'; for example, 
> the simple ver() and a method that generates an integer sequence:
> 
>   sub genSeq_IndexOps($limit, $f) is export {
> my @a = ();
> for (0...^$limit) -> $n {
>   @a.push($f($n));
> }
> return @a;
>   }
> 
> So the module is being found and used. It seems as if certain methods aren't 
> being found.
> 
> I am not convinced that the problem I'm having is unrelated to the issue 
> raised concerning the REPL. When I use the REPL, the results are the same.
> 
> [0] > use SequenceHelper;
> Nil
> [1] > say ver();
> v0.0.1
> [1] > say 4!;
> ===SORRY!=== Error while compiling:
> Negation metaoperator not followed by valid infix
> [1] > put genSeq_IndexOps(15, -> $x {3**$x + 5**$x + 6**$x});
> 3 14 70 368 2002 11144 63010 360248 2076802 12050504 70290850 411802328 
> 2421454402 14282991464 84472462690
> 
> Regards,
> 
> Joe
> 



Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Parrot Raiser
The cause of the problem may well need to be fixed for other reasons,
but re-purposing an almost universal operator like "!" ("not") sounds
like a thoroughly bad idea, the route to non-standard code.

If you must have a factorial operator, what's wrong with defining "Fact"?

On 10/14/22, Elizabeth Mattijsen  wrote:
> I cannot reproduce:
>
> % cat lib/A.rakumod
> sub postfix: ($n) is export {
> when $n == 0 {return 1}
> default {$n * ($n - 1)!}
> }
> % raku -e 'use lib "lib"; use A; say 42!'
> 14050061177528798985431426062445115699363840
> % raku -v
> Welcome to Rakudo™ v2022.07-64-gce1af0fa0.
> Implementing the Raku® Programming Language v6.d.
> Built on MoarVM version 2022.07-16-g3ae8a31c1.
>
>> On 14 Oct 2022, at 05:30, Joseph Polanik  wrote:
>>
>>
>> On 10/13/22 9:19 PM, Ralph Mellor wrote:
>>> On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik 
>>> wrote:
 I am trying to define '!' as the factorial operator. The following
 works
 in a .raku script file:

sub postfix: ($n) is export {
  when $n == 0 {return 1}
  default {$n * ($n - 1)!}
}

 However when I tried to move this sub to a .rakumod file,
 it produces an error: Negation metaoperator not followed
 by valid infix.
>>> That's because Raku isn't picking up your `sub`.
>>>
>>> I don't know why. It works for me. (v2022.02)
>>>
>>> Are you sure you're `use`ing it correctly and the `sub`
>>> has the `is export`?
>>
>> Yes, the sub that defines the factorial operator is marked with 'is
>> export' and the script that invokes my module (SequenceHelper) has a 'use'
>> statement.
>>
>> The script is able to invoke other methods marked 'is export'; for
>> example, the simple ver() and a method that generates an integer
>> sequence:
>>
>>   sub genSeq_IndexOps($limit, $f) is export {
>> my @a = ();
>> for (0...^$limit) -> $n {
>>   @a.push($f($n));
>> }
>> return @a;
>>   }
>>
>> So the module is being found and used. It seems as if certain methods
>> aren't being found.
>>
>> I am not convinced that the problem I'm having is unrelated to the issue
>> raised concerning the REPL. When I use the REPL, the results are the
>> same.
>>
>> [0] > use SequenceHelper;
>> Nil
>> [1] > say ver();
>> v0.0.1
>> [1] > say 4!;
>> ===SORRY!=== Error while compiling:
>> Negation metaoperator not followed by valid infix
>> [1] > put genSeq_IndexOps(15, -> $x {3**$x + 5**$x + 6**$x});
>> 3 14 70 368 2002 11144 63010 360248 2076802 12050504 70290850 411802328
>> 2421454402 14282991464 84472462690
>>
>> Regards,
>>
>> Joe
>>
>
>


Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik

On 10/14/22 4:32 AM, Elizabeth Mattijsen wrote:

I cannot reproduce:

% cat lib/A.rakumod
sub postfix: ($n) is export {
 when $n == 0 {return 1}
 default {$n * ($n - 1)!}
}
% raku -e 'use lib "lib"; use A; say 42!'
14050061177528798985431426062445115699363840


Very helpful. I have 6 subs in my module and all 6 work correctly when 
invoked from the system command line.


# Verify version
raku -e 'use lib "lib"; use SequenceHelper; say ver()';
# v0.0.1

# Verify factorial operator
raku -e 'use lib "lib"; use SequenceHelper; say 42!';
# 14050061177528798985431426062445115699363840

# Verify double factorial operator
raku -e 'use lib "lib"; use SequenceHelper; say 5!!';
# 15

# Generate a sequence using genSeq_IndexOps
raku -e 'use lib "lib"; use SequenceHelper; say genSeq_IndexOps(5, -> $x 
{3**$x + 5**$x + 6**$x})';

# [3 14 70 368 2002]

# Generate a sequence using genSeq_ArrayOps
raku -e 'use lib "lib"; use SequenceHelper; say genSeq_ArrayOps(11, -> 
$x, @z {@z[$x-1] + @z[$x-2]}, <0 1>)';

# [0 1 1 2 3 5 8 13 21 34 55]

#Verify Palindrome detector
raku -e 'use lib "lib"; use SequenceHelper; say is-palindrome("noon")';

#True

Each of these results is correct. So, the problem remains that some subs 
are not found when invoked either from a test script or from the REPL.


Is there some cache that I must clear when changing a .rakumod file to 
prevent my system from hanging on to old material?


Regards,

Joe




Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen
> On 14 Oct 2022, at 20:35, Joseph Polanik  wrote:
> Each of these results is correct. So, the problem remains that some subs are 
> not found when invoked either from a test script or from the REPL.
> 
> Is there some cache that I must clear when changing a .rakumod file to 
> prevent my system from hanging on to old material?

No, that's the whole point of `use lib "foo"`: it will checksum all files in 
"foo" *and* its subdirectoroies, and will recompile if *any* file changed.


Liz

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik

On 10/14/22 11:39 AM, Parrot Raiser wrote:

The cause of the problem may well need to be fixed for other reasons,
but re-purposing an almost universal operator like "!" ("not") sounds
like a thoroughly bad idea, the route to non-standard code.

If you must have a factorial operator, what's wrong with defining "Fact"?


! meaning 'not' is a prefix operator. ! meaning factorial is a postfix 
operator. So, the two can co-exist.


Actually, I did create a factorial() sub, but that didn't get me out of 
my present predicament. It works as expected when invoked from the 
command line. However, when invoked from a test script (or the REPL) the 
error message is "Undeclared routine".


Regards,

Joe





Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen
> On 14 Oct 2022, at 21:15, Joseph Polanik  wrote:
> Actually, I did create a factorial() sub, but that didn't get me out of my 
> present predicament. It works as expected when invoked from the command line. 
> However, when invoked from a test script (or the REPL) the error message is 
> "Undeclared routine".

Could you please run that case with:

$ raku --ll-exception -Idir-with-module test-script

and post the output?


Liz

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik

On 10/14/22 3:38 PM, Elizabeth Mattijsen wrote:

On 14 Oct 2022, at 21:15, Joseph Polanik  wrote:
Actually, I did create a factorial() sub, but that didn't get me out 
of my present predicament. It works as expected when invoked from the 
command line. However, when invoked from a test script (or the REPL) 
the error message is "Undeclared routine".

Could you please run that case with:

$ raku --ll-exception -Idir-with-module test-script

and post the output?

$ raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku
Undeclared routine:
    factorial used at line 23

   at SETTING::src/core.c/Exception.pm6:64 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/CORE.c.setting.moarvm:throw) 

 from gen/moar/Grammar.nqp:4517 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:cry_sorrows) 

 from gen/moar/Grammar.nqp:838 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:comp_unit) 

 from gen/moar/Grammar.nqp:553 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:TOP) 

 from gen/moar/stage2/QRegex.nqp:2267 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/QRegex.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2301 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2217 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:execute_stage) 

 from gen/moar/stage2/NQPHLL.nqp:2252 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:run)
 from gen/moar/stage2/NQPHLL.nqp:2248 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:)
 from gen/moar/stage2/NQPHLL.nqp:2244 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:compile) 

 from gen/moar/stage2/NQPHLL.nqp:1919 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:eval)
 from gen/moar/stage2/NQPHLL.nqp:2154 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:evalfiles) 

 from gen/moar/stage2/NQPHLL.nqp:2114 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_eval) 

 from gen/moar/Compiler.nqp:105 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Compiler.moarvm:command_eval) 

 from gen/moar/stage2/NQPHLL.nqp:2039 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_line) 

 from gen/moar/rakudo.nqp:140 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:MAIN) 

 from gen/moar/rakudo.nqp:1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:) 

 from :1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:) 

 from :1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:) 



The script Run/run_SequenceHelper.raku contains only the following lines

use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
use SequenceHelper :ALL;
say factorial(5);

Thanks for looking into this.

Joe



Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen



> On 14 Oct 2022, at 22:05, Joseph Polanik  wrote:
> 
> On 10/14/22 3:38 PM, Elizabeth Mattijsen wrote: 
>>> On 14 Oct 2022, at 21:15, Joseph Polanik  wrote: 
>>> Actually, I did create a factorial() sub, but that didn't get me out of my 
>>> present predicament. It works as expected when invoked from the command 
>>> line. However, when invoked from a test script (or the REPL) the error 
>>> message is "Undeclared routine". 
>> Could you please run that case with: 
>> 
>> $ raku --ll-exception -Idir-with-module test-script 
>> 
>> and post the output? 
> $ raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku 
> Undeclared routine: 
> factorial used at line 23 
> 
>at SETTING::src/core.c/Exception.pm6:64 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/CORE.c.setting.moarvm:throw)
>  
>  from gen/moar/Grammar.nqp:4517 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:cry_sorrows)
>  
>  from gen/moar/Grammar.nqp:838 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:comp_unit)

So, this is really the static optimizer complaining about the fact that 
"factorial" did not actually got exported.


> The script Run/run_SequenceHelper.raku contains only the following lines 
> 
> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib'; 
> use SequenceHelper :ALL;

OOC, what happens if you remove the :ALL here?


Liz

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik

On 10/14/22 4:15 PM, Elizabeth Mattijsen wrote:


The script Run/run_SequenceHelper.raku contains only the following lines

use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
use SequenceHelper :ALL;

OOC, what happens if you remove the :ALL here?


No change that I can see:

raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku
Undeclared routine:
    factorial used at line 23

   at SETTING::src/core.c/Exception.pm6:64 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/CORE.c.setting.moarvm:throw)
 from gen/moar/Grammar.nqp:4517 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:cry_sorrows)
 from gen/moar/Grammar.nqp:838 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:comp_unit)
 from gen/moar/Grammar.nqp:553 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:TOP)
 from gen/moar/stage2/QRegex.nqp:2267 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/QRegex.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2301 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2217 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:execute_stage)
 from gen/moar/stage2/NQPHLL.nqp:2252 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:run)
 from gen/moar/stage2/NQPHLL.nqp:2248 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:)
 from gen/moar/stage2/NQPHLL.nqp:2244 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:compile)
 from gen/moar/stage2/NQPHLL.nqp:1919 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:eval)
 from gen/moar/stage2/NQPHLL.nqp:2154 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:evalfiles)
 from gen/moar/stage2/NQPHLL.nqp:2114 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_eval)
 from gen/moar/Compiler.nqp:105 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Compiler.moarvm:command_eval)
 from gen/moar/stage2/NQPHLL.nqp:2039 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_line)
 from gen/moar/rakudo.nqp:140 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:MAIN)
 from gen/moar/rakudo.nqp:1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
 from :1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
 from :1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)


Joe




Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen



> On 14 Oct 2022, at 22:23, Joseph Polanik  wrote:
> 
> On 10/14/22 4:15 PM, Elizabeth Mattijsen wrote:
> 
>> The script Run/run_SequenceHelper.raku contains only the following lines
>>> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
>>> use SequenceHelper :ALL;
>> OOC, what happens if you remove the :ALL here?
> 
> No change that I can see:
> 
> raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku

I hope you changed "dir-with-module" by the actual directory name.

> Undeclared routine:
> factorial used at line 23

Do you happen to have a subroutine called "EXPORT" in the module?


Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik

On 10/14/22 4:53 PM, Elizabeth Mattijsen wrote:

raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku
I hope you changed "dir-with-module" by the actual directory name.


I didn't. My bad. Now, four subs are producing correct results

raku --ll-exception 
-I/home/jpolanik/Documents/myRaku/gitHub/SequenceHelper/lib/ 
Run/run_SequenceHelper.raku


Invoke factorial operator
120

Invoke factorial sub
120

Invoke double factorial operator
15

Invoke is-palindrome
True

The other two methods, genSeq_IndexOps and  genSeq_ArrayOps, are 
producing errors:


raku --ll-exception 
-I/home/jpolanik/Documents/myRaku/gitHub/SequenceHelper/lib/ 
Run/run_SequenceHelper.raku

Two terms in a row across lines (missing semicolon or comma?)
   at SETTING::src/core.c/Exception.pm6:64 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/CORE.c.setting.moarvm:throw)
 from gen/moar/World.nqp:5447 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/World.moarvm:throw)
 from gen/moar/Grammar.nqp:295 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:typed_panic)
 from gen/moar/Grammar.nqp:991 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:eat_terminator)
 from gen/moar/Grammar.nqp:890 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:statementlist)
 from gen/moar/stage2/NQPHLL.nqp:1471 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:LANG)
 from gen/moar/Grammar.nqp:1342 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:FOREIGN_LANG)
 from gen/moar/Grammar.nqp:838 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:comp_unit)
 from gen/moar/Grammar.nqp:553 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:TOP)
 from gen/moar/stage2/QRegex.nqp:2267 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/QRegex.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2301 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:parse)
 from gen/moar/stage2/NQPHLL.nqp:2217 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:execute_stage)
 from gen/moar/stage2/NQPHLL.nqp:2252 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:run)
 from gen/moar/stage2/NQPHLL.nqp:2248 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:)
 from gen/moar/stage2/NQPHLL.nqp:2244 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:compile)
 from gen/moar/stage2/NQPHLL.nqp:1919 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:eval)
 from gen/moar/stage2/NQPHLL.nqp:2154 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:evalfiles)
 from gen/moar/stage2/NQPHLL.nqp:2114 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_eval)
 from gen/moar/Compiler.nqp:105 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Compiler.moarvm:command_eval)
 from gen/moar/stage2/NQPHLL.nqp:2039 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_line)
 from gen/moar/rakudo.nqp:140 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:MAIN)
 from gen/moar/rakudo.nqp:1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
 from :1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
 from :1 
(/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)


I'll keep playing with those two malfunctions.

Joe








Do you happen to have a subroutine called "EXPORT" in the module?


No




Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Vadim Belman
I like the way you use ~ in `use lib '~/...';`. Though it doesn't work as 
expected. But it's nice! :D

Best regards,
Vadim Belman

> On Oct 14, 2022, at 4:05 PM, Joseph Polanik  wrote:
> 
> On 10/14/22 3:38 PM, Elizabeth Mattijsen wrote: 
>>> On 14 Oct 2022, at 21:15, Joseph Polanik  
>>>  wrote: 
>>> Actually, I did create a factorial() sub, but that didn't get me out of my 
>>> present predicament. It works as expected when invoked from the command 
>>> line. However, when invoked from a test script (or the REPL) the error 
>>> message is "Undeclared routine". 
>> Could you please run that case with: 
>> 
>> $ raku --ll-exception -Idir-with-module test-script 
>> 
>> and post the output? 
> $ raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku 
> Undeclared routine: 
> factorial used at line 23 
> 
>at SETTING::src/core.c/Exception.pm6:64 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/CORE.c.setting.moarvm:throw)
>  
>  from gen/moar/Grammar.nqp:4517 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:cry_sorrows)
>  
>  from gen/moar/Grammar.nqp:838 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:comp_unit)
>  
>  from gen/moar/Grammar.nqp:553 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:TOP)
>  
>  from gen/moar/stage2/QRegex.nqp:2267 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/QRegex.moarvm:parse) 
>  from gen/moar/stage2/NQPHLL.nqp:2301 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:parse) 
>  from gen/moar/stage2/NQPHLL.nqp:2217 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:execute_stage)
>  
>  from gen/moar/stage2/NQPHLL.nqp:2252 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:run) 
>  from gen/moar/stage2/NQPHLL.nqp:2248 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:) 
>  from gen/moar/stage2/NQPHLL.nqp:2244 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:compile) 
>  from gen/moar/stage2/NQPHLL.nqp:1919 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:eval) 
>  from gen/moar/stage2/NQPHLL.nqp:2154 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:evalfiles)
>  
>  from gen/moar/stage2/NQPHLL.nqp:2114 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_eval)
>  
>  from gen/moar/Compiler.nqp:105 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Compiler.moarvm:command_eval)
>  
>  from gen/moar/stage2/NQPHLL.nqp:2039 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/nqp/lib/NQPHLL.moarvm:command_line)
>  
>  from gen/moar/rakudo.nqp:140 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:MAIN)
>  
>  from gen/moar/rakudo.nqp:1 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
>  
>  from :1 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
>  
>  from :1 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/perl6.moarvm:)
>  
> 
> The script Run/run_SequenceHelper.raku contains only the following lines 
> 
> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib'; 
> use SequenceHelper :ALL; 
> say factorial(5); 
> 
> Thanks for looking into this. 
> 
> Joe 
> 
> 



Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Bruce Gray



> On Oct 14, 2022, at 3:23 PM, Joseph Polanik  wrote:
> 
>> The script Run/run_SequenceHelper.raku contains only the following lines
>>> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
>>> use SequenceHelper :ALL;

--snip--

A possible piece of the puzzle is that your `use` line is silently failing,
because the `~` tilde character is not special to Raku.
Instead of:
use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
, you need either of these:
use lib "%*ENV/Documents/myRaku/gitHub/SequenceHelper/lib";
use lib  %*ENV ~ '/Documents/myRaku/gitHub/SequenceHelper/lib';

Therefore, the module you have been testing might not be the one you thought 
you were testing.

To demonstrate, notice that in the error message below, the first search path 
contains the literal "Junk/~".
cd ~/Junk
raku -e 'use lib "~/FakeDir"; use FakeModule;'
===SORRY!=== Error while compiling -e
Could not find FakeModule in:
file#/Users/bruce_pro/Junk/~/FakeDir
...


-- 
Hope this helps,
Bruce Gray (Util of PerlMonks)

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik
Update: I was missing a couple of commas. Now all methods are reporting 
correct results.


raku --ll-exception 
-I/home/jpolanik/Documents/myRaku/gitHub/SequenceHelper/lib/ 
Run/run_SequenceHelper.raku


Invoke factorial operator
120

Invoke factorial sub
120

Invoke double factorial operator
15

Invoke is-palindrome
True

Invoke genSeq_IndexOps
[3 14 70 368 2002]

Invoke genSeq_ArrayOps
[0 1 1 2 3 5 8 13 21 34 55]

Thanks for the help.

Joe




Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Ralph Mellor
On Fri, Oct 14, 2022 at 10:59 PM Joseph Polanik  wrote:
>
> Update: ... all methods are reporting correct results.
>
> Thanks for the help.

Good to see resolution of problems. :)

Is everything now resolved or are some things still outstanding?

--
love, raiph


Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik

On 10/14/22 5:48 PM, Bruce Gray wrote:

On Oct 14, 2022, at 3:23 PM, Joseph Polanik  wrote:
The script Run/run_SequenceHelper.raku contains only the following lines

use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
use SequenceHelper :ALL;

--snip--

A possible piece of the puzzle is that your `use` line is silently failing,
because the `~` tilde character is not special to Raku.
Instead of:
 use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
, you need either of these:
 use lib "%*ENV/Documents/myRaku/gitHub/SequenceHelper/lib";
 use lib  %*ENV ~ '/Documents/myRaku/gitHub/SequenceHelper/lib';

Therefore, the module you have been testing might not be the one you thought 
you were testing.

To demonstrate, notice that in the error message below, the first search path contains 
the literal "Junk/~".
 cd ~/Junk
 raku -e 'use lib "~/FakeDir"; use FakeModule;'
 ===SORRY!=== Error while compiling -e
 Could not find FakeModule in:
 file#/Users/bruce_pro/Junk/~/FakeDir
 ...


Bruce and Vadim. I've removed the tilde as a precaution.

Thanks for the comment.

Joe




Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Joseph Polanik



On 10/14/22 6:03 PM, Ralph Mellor wrote:

On Fri, Oct 14, 2022 at 10:59 PM Joseph Polanik  wrote:

Update: ... all methods are reporting correct results.

Thanks for the help.

Good to see resolution of problems. :)

Is everything now resolved or are some things still outstanding?

--
love, raiph


I believe that my problem is resolved; so, you were right in that it had 
nothing to do with the problems with the REPL.


Regards,

Joe



Re: Problem defining factorial operator in .rakumod file

2022-10-19 Thread Brian Duggan
On Friday, October 14, Bruce Gray wrote: 
> because the `~` tilde character is not special to Raku.
> Instead of:
> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
> , you need either of these:
> use lib "%*ENV/Documents/myRaku/gitHub/SequenceHelper/lib";
> use lib  %*ENV ~ '/Documents/myRaku/gitHub/SequenceHelper/lib';

There is also $*HOME, so this could be written as:

   use lib $*HOME.child('Documents/myRaku/gitHub/SequenceHelper/lib')

Brian