01:30 SmokeMachine_ joined 01:39 SmokeMachine left, SmokeMachine_ is now known as SmokeMachine 02:40 frost joined 08:11 discord-raku-bot left 08:12 discord-raku-bot joined 10:51 frost left
gfldex m:``` 14:14
sub needle(\b) {
sub is-pentagon($c is raw) { (1+sqrt(1+24*$c))%%6 }
sub P($n is raw) { $n*(3*$n-1) div 2 }
for (1..^b) -> \s {
my \bp = P(b);
my \sp = P(s);
if is-pentagon(bp + sp) && is-pentagon(bp - sp) {
return |(b, s);
}
}
}
sub infix:<notnilor>(\maybenil, \alternative) {
maybenil =:= Nil ?? alternative !! maybenil
}
say (^āˆž).hyper(:batch(8), :degree(16)).map({.&needle notnilor Empty }).head;
say now - BEGIN now;
```
It took me a whole blogpost to realise that HyperSeq are inherently lazy.
stevied I can't seem to place a variable inside %?RESOURCES accessor: `%?RESOURCES<$tmpl>.slurp` 14:53
but `%?RESOURCES<something.json>.slurp` works
ok, figured it out. need {} to do interpolation 14:56
ugh.
How do I dynamically load a class at runtime? I'm not getting anywhere with: 16:59
```
my $tmpl = basename $config;
my $tpl_class = "Karabiner::Templates::$tmpl";
require ::("Karabiner::Templates::ActivateApps");
my &class_create = ::("Karabiner::Templates::ActivateApps::&create");
```
ok, got it. the examples here helped: docs.raku.org/language/packages#in...entry-::() 17:47
I got this: 18:08
```
my $tmpl = basename $config;
if (try require ::("Karabiner::Templates::$tmpl")) === Nil {
}
```
it keeps throwing an error: `Use of Nil in string context` 18:09
how can I test if the file gets required in?
18:10 Util_ left
Anton Antonov I am not sure what you mean. The "easy answer" is "by scanning the code." 18:12
stevied I'm trying to follow the example at: docs.raku.org/language/modules#require 18:16
it has example code to determine if a module is loaded.
I can't get it to work. I keep getting the error `Use of Nil in string context`
no idea how to fix it
Anton Antonov Do you mean this:
```
# Use return value to test whether loading succeeded:
(try require Foo) === Nil and say "Failed to load Foo!";
```
(It seems so -- I read more carefully you previous messages.) 18:18
stevied yes, I tried that already. got the same error
Anton Antonov Meaning, "got it" not "keep doing that".
stevied right
Anton Antonov Very strange! See this: 18:30
Ah, I pasted the wrong screenshot -- I have an assignment to `$val`. 18:31
It looks like this works: 18:42
```
use silently;
silently { requireĀ ::("Lingua::" ~ $namePart ~ '7') }
ifĀ ::("Lingua::" ~ $namePart ~ '7') Ā ~~Ā FailureĀ {
Ā Ā Ā Ā sayĀ "FailedĀ toĀ load!";
}
```
I am using the "silently" module : raku.land/zef:lizmat/silently 18:43
stevied hmm. ok. why so I need that?
do 18:44
Anton Antonov Otherwise you will get the `Nil` message... šŸ™‚ 18:45
Basically, sweeping that message under the rug...
stevied ok. but I'm totally lost. this seems insane
Anton Antonov It is not good.
Definitely a discrepancy with what is documented.
stevied alright, so I should just chalk it up to a big of ugliness and hope they fix it?
bit
Anton Antonov Hmm... yeah, this needs to be reported. 18:47
*I am not that this today though...*
*I am not doing that today though...*
stevied ok
I can do it but I won't really be able to explain what's going on in the report
when I run the require function inside silently{}, I get an error saying it can't find my module 19:00
`No such symbol 'Karabiner::Templates::ActivateApps'` 19:01
i don't get that error when run outside of `silently`
something feels badly broken. 19:03
yeah, so I got this: 19:13
```
my $tmpl = basename $config;
my $blah = (require ::("Karabiner::Templates::$tmpl"));
say $blah.raku;
```
that returns: 19:14
`Failure.new(exception => X::NoSuchSymbol.new(symbol => "Karabiner::Templates::ActivateApps"), backtrace => Backtrace.new)`
but I know that the module is getting loaded because the rest of the code uses it 19:16
when the module doesn't exist at all, I get a different error: 19:18
```
Could not find Karabiner::Templats::ActivateApps in:
file#/Users/stevedondley/git_repos/raku/modules/steve/Karabiner-CompModGenerator/lib
inst#/Users/stevedondley/.raku
inst#/Users/stevedondley/rakudo-moar-2021.12-01-macos-x86_64-clang/share/perl6/site
inst#/Users/stevedondley/rakudo-moar-2021.12-01-macos-x86_64-clang/share/perl6/vendor
inst#/Users/stevedondley/rakudo-moar-2021.12-01-macos-x86_64-clang/share/perl6/core
ap#
nqp#
perl5#
in sub generate_output at /Users/stevedondley/git_repos/raku/modules/steve/Karabiner-CompModGenerator/lib/Karabiner/CompModGenerator.rakumod (Karabiner::CompModGenerator) line 9
seems like it's throwing an error when it shouldn't be
Anton Antonov Yeah, more or less this what I get too. 19:53
20:03 qorg11 left 20:05 qorg11 joined