00:00 Doc_Holliwood left 00:05 vrurg joined 00:08 JRaspass left 00:09 vrurg left 00:10 MasterDuke left 00:29 pecastro left 00:46 leont left 01:03 vrurg joined 01:22 xinming_ left 01:24 xinming_ joined 01:30 vike joined 01:42 JRaspass joined 01:43 xinming_ left 01:45 xinming_ joined 01:54 aborazmeh_ left 01:55 JRaspass left 02:10 grumble left 02:14 grumble joined 02:19 gnufr33dom joined 02:28 lnx joined 02:32 simcop2387 left 02:36 kvw_5_ joined 02:39 kvw_5 left 02:40 mowotter joined 02:41 mowotter left 02:42 mowcat left
vrurg . 02:47
02:52 mowcat joined, Garbanzo joined 02:54 mowcat left 03:01 klapperl left, klapperl joined 03:04 Bucciarati left, avar left 03:16 Bucciarati joined, avar joined, avar left, avar joined 03:22 jmcgnh left 03:30 lnx left 03:31 lnx joined 03:52 xinming_ left 03:53 xinming_ joined 03:59 jmcgnh joined 04:02 DiffieHellman left 04:03 bartolin left 04:04 xelxebar left 04:15 xinming_ left, xinming_ joined, simcop2387 joined, simcop2387 left, simcop2387 joined 04:16 xelxebar joined, DiffieHellman joined 04:17 bartolin joined 04:20 DiffieHellman left 04:22 DiffieHellman joined 04:57 xinming_ left 04:58 xinming_ joined 05:29 xinming_ left, xinming_ joined 05:49 xinming_ left 05:50 xinming_ joined 05:57 kaiwulf left
summerisle i have to write a bunch of basic python for this stupid entry-level course i'm doing for giggles, and my god is it really the fortran of the 21st century. it's so prescriptive and bland. 06:04
06:07 jmerelo joined 06:33 frost-lab joined
parabolize schools seem to abuse python alot 06:36
06:41 ufobat_ joined 06:52 xinming joined 06:55 xinming_ left 07:20 Discipulus joined 07:31 parabolize left 07:34 aborazmeh joined 07:35 Garbanzo left 07:41 stoned75 joined
summerisle i've always disliked python's intentionally restrictive design. i suppose its merits are reflected in the fact that it's popular in the scientific computing community (e.g. lots of people that don't know how to write good code but need to write code) 07:46
07:48 aborazmeh left
summerisle hence my calling it 21st century fortran. 07:49
07:49 wamba joined
summerisle of course, one can make an absolute butchery of python or fortran 07:49
i'd be fine if it would just stay confined to that community, but would really appreciate it if the linux world could distance itself from python a little more 07:51
07:56 stoned75 left 07:58 domidumont joined 08:11 pecastro joined 08:25 Sgeo left 08:26 patrickb joined 08:31 MasterDuke joined 08:51 Doc_Holliwood joined 08:52 dakkar joined 08:57 sortiz left 08:59 sena_kun left 09:02 sena_kun joined 09:07 leont joined 09:12 Geth joined
lizmat clickbaits rakudoweekly.blog/2021/03/01/2021-...t-of-raku/ 09:20
kawaii I'm looking at `head` and `tail` methods on the Array type but maybe there's an easier way - I have an array with x number of items, I'd like to split it into @array1 with the first 2 items, and all the remaining into @array2, but I don't know how many are remaining so I don't think I can just use `tail`, can I? 09:30
09:33 JRaspass joined 09:35 abraxxa left
El_Che lo 09:35
kawaii o/ 09:39
tyil \o
MasterDuke kawaii: maybe destructuring? 09:42
lizmat kawaii: does the original array need to be untouched? 09:44
if not, then something simple like:
m: my @a = ^10; my @b = @a.shift xx 2; dd @a, @b'
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3 = ^10; my @b = @a.shift xx 2; dd @a, @b7⏏5'
expecting any of:
infix
infix stopper
postfix
statement end
lizmat Array @a = [2, 3, 4, 5, 6, 7, 8, 9]
m: my @a = ^10; my @b = @a.shift xx 2; dd @a, @b 09:45
camelia Array @a = [2, 3, 4, 5, 6, 7, 8, 9]
Array @b = [0, 1]
lizmat if you just need to iterate 09:46
m: my @a = ^10; .say for @a.head(2); .say for @a.tail(*-2)
camelia 0
1
2
3
4
5
6
7
8
9
lizmat hmmm
m: my @a = ^10; .say for @a.head(2); say "SWITCH"; .say for @a.tail(*-2) 09:47
camelia 0
1
SWITCH
2
3
4
5
6
7
8
9
kawaii lizmat: let me try some of these, thanks :) 09:48
works perfectly, thanks liz 09:50
09:57 xinming left 09:59 abraxxa joined 10:00 xinming joined 10:01 frost-lab left 10:03 abraxxa left 10:04 abraxxa joined 10:13 frost-lab joined 10:15 mniip left
kawaii I never understand these Seq errors, surely it's not in use because I'm just reading it, not mutating it? www.irccloud.com/pastebin/tMaMzKm9/ 10:17
(error in reference to the head and tail methods)
lizmat with filters => foo.map you're effectively binding the Seq to the hash 10:19
you could follow the suggestion of the error, and add .cache to the expression you put in %assets<filters> 10:20
otoh, I wonder if we could get Hash.STORE do that automatically for you 10:21
10:22 mniip joined
lizmat m: my $a = ^10 .map(*.Str); dd $a.head(2); dd $a.tail(2) 10:22
camelia ("0", "1").Seq
The iterator of this Seq is already in use/consumed by another Seq
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <tmp> line 1
lizmat is basically the issue
m: my $a = ^10 .map(*.Str).cache; dd $a.head(2); dd $a.tail(2)
camelia ("0", "1").Seq
("8", "9").Seq
lizmat kawaii: does that make sense? 10:23
kawaii lizmat: yes, thank you for the examples :)
lizmat BTW, looking at your code, it feels you could be better off creating an Assets object 10:24
with defaults/ filters / pandoc-version / warp-version / etc. attributes
and handle the logic in a TWEAK method
you could then use @.filters as the attribute name, and then you wouldn't have the Seq issues 10:25
kawaii Maaaaaybe, this is what I could get working with Cro's template system, which seems to only allow you to pass one "thing" into it for use
lizmat m: my @a = ^10 .map(*.Str); dd @a.head(2); dd @a.tail(2)
camelia ("0", "1").Seq
("8", "9").Seq
lizmat pretty sure Cro's template system also allows methods to be called on the one thing you pass ? 10:26
kawaii Oh right, yeah 10:27
10:27 xinming left
kawaii So I have an assets object and call stuff like `.version` etc on it 10:27
10:28 xinming joined
lizmat class Assets { has @.defaults; has @.filters, has $.pandoc-version, has $.warp-version; method filter-pre() { @!filters.head(2) } ... 10:30
10:35 frost-lab left 10:42 berber44 joined 10:46 patrickb left 10:59 Doc_Holliwood left 11:01 xelxebar left, xelxebar joined
leont m: my &foo = -> { return 42 }; sub bar() { foo(); }; bar(); 11:15
camelia Attempt to return outside of any Routine
in block <unit> at <tmp> line 1
leont I thought that would be legal
Is there any way for me to achieve such a thing?
dakkar pointy blocks aren't routines 11:16
m: my &foo = -> { 42 }; sub bar() { foo(); }; say bar();
camelia 42
dakkar (otherwise `for @a -> $a { return 2 }` would be a bit surprising)
11:17 xinming left
leont I know 11:17
I should have been more specific
I *want* to return from &bar by doing so in &foo
dakkar ah! hmmm 11:18
11:19 xinming joined
leont Then again, I can use last instead, and catch the CX::Last in a CONTROL. Might even look better in my particular case. 11:20
lizmat hmmm... I wonder what the optimization implications are of catching CX::Last control exceptions 11:25
dakkar if I run that code in the repl, it says "Control flow commands not allowed in toplevel" 11:26
11:30 hythm joined 11:33 xinming left 11:35 hythm left, xinming joined 11:36 hythm joined
xinming What is the idiom to append blob to a file? 11:37
lizmat "file".IO.spurt(blob, :append) ? 11:38
if that doesn't work, maybe it should ?
xinming lizmat: This way, It'll always open-close the file,
lizmat well, you did say "file" not "handle" ?
xinming What I mean is something like, given $fh { ...; .append(...); ... } 11:39
But we need to open the $fh before hand 11:40
lizmat "file".IO.open(:append).spurt(Blob) ?
xinming lizmat: Thanks, this is what I want.
lizmat my $h = "file".IO.open(:append); $h.spurt(Blob) ? 11:41
:q
oops :-)
xinming thanks, the .IO.open(:append) is what I want. Will try.
11:42 PimDaniel joined
PimDaniel \o 11:42
What is a constant in raku? 11:43
lizmat my constant FOO = 42;
xinming PimDaniel: my \a = 42;
I never thought we have my constant :-)
lizmat xinming
PimDaniel Ok now : How may we express a constant in a hash key? 11:44
lizmat my constant FOO = 42 is equivalent to:
my \FOO = BEGIN 42
dakkar m: my constant foo=1;foo=3;
camelia Cannot modify an immutable Int (1)
in block <unit> at <tmp> line 1
dakkar m: my constant $foo=1;$foo=3;
camelia Cannot assign to an immutable value
in block <unit> at <tmp> line 1
dakkar interesting difference in error message (reflecting the extra container, I guess) 11:45
PimDaniel ok may we express constant directly into a hash key?
lizmat he...intriguing
%foo<bar> # PimDaniel?
m: my \FOO = 42; BEGIN say FOO # xinming 11:46
camelia (Mu)
lizmat m: my constant FOO = 42; BEGIN say FOO # xinming
camelia 42
hythm Hello, anyone knows of an article or a blog post that explains compile time and runtime in a Raku program? sometimes I see people refering to some parts in code, that it will be executed at compile time or at runtime, and I wonder how could they tell. so I wonder if there is an article that is discussing a Raku program line by line and explaining why this piece of code is executed at compile while this one at runtime.
PimDaniel lizmat : bar will NOT be the value of the constant but the string 'bar' 11:47
for now i must do Str $MYCONST = bar; and insert $MYCONST into hash definition. 11:49
lizmat PimDaniel: not quite sure I follow, could you create a gist ?
dakkar m: my constant THEKEY='bar'; my %hash; %hash{THEKEY}=1; %hash
camelia WARNINGS for <tmp>:
Useless use of %hash in sink context (line 1)
dakkar m: my constant THEKEY='bar'; my %hash; %hash{THEKEY}=1; say %hash
camelia {bar => 1}
dakkar PimDaniel: that?
postfix braces contain an expression, postfix angle-brackets work like quotes 11:50
PimDaniel I must precise: i use positionals : key => val,keynext => nextval, ...
and it's a new method entry. 11:51
lizmat m: my \FOO = "foo"; my %h = (FOO) => "bar"; dd %h 11:52
camelia Hash %h = {:foo("bar")}
dakkar yes but…
lizmat :w 11:53
argh :-)
dakkar m: my \KEY='foo';sub x(:$foo) {}; x( KEY => 1 )
camelia Unexpected named argument 'KEY' passed
in sub x at <tmp> line 1
in block <unit> at <tmp> line 1
dakkar m: my \KEY='foo';sub x(:$foo) {}; x( (KEY) => 1 )
camelia Too many positionals passed; expected 0 arguments but got 1
in sub x at <tmp> line 1
in block <unit> at <tmp> line 1
dakkar looks like the parser behaves differently in an arglist
11:53 xinming left 11:54 xinming joined
lizmat yeah, only bareword fatcomma is interpreted as named argument, I believe purposely so 11:54
PimDaniel I try parentesis... 11:55
It seams to work for what i'm doing. 11:56
May be :A,:B,... whould be better? No? 11:57
Hum , No, i's anothe way to write positionals. 11:58
Ok thank's i will try this way for now.
back later... 11:59
11:59 PimDaniel left
hythm oh, I dound this helpful slides here archive.fosdem.org/2015/schedule/e...ynamic.pdf (Don't know why cdidn't see it the first time I searched about that subject) 12:05
s/dound/found/ 12:07
Geth ecosystem/finanalyst-patch-4: 2549a34142 | (Richard Hainsworth)++ (committed using GitHub Web editor) | META.list
Add Collection-Raku-Documentation

Creates a Collection version of Raku Documentation. github.com/finanalyst/collection-r...umentation Currently, static files generated with this system can be seen at raku.finanalyst.org
12:09
ecosystem: finanalyst++ created pull request #584:
Add Collection-Raku-Documentation
12:10
ecosystem: 2549a34142 | (Richard Hainsworth)++ (committed using GitHub Web editor) | META.list
Add Collection-Raku-Documentation

Creates a Collection version of Raku Documentation. github.com/finanalyst/collection-r...umentation Currently, static files generated with this system can be seen at raku.finanalyst.org
ecosystem: 29a61464b1 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Merge pull request #584 from Raku/finanalyst-patch-4

Add Collection-Raku-Documentation
12:53 patrickb joined 13:13 vike left 13:15 jmerelo left 13:28 wamba left 13:29 vike joined 13:44 xinming left 13:45 xinming joined
dakkar PimDaniel: lizmat: this works, to pass a named argument whose name is in a constant (or any expression, for that matter): `my constant KEY="foo";sub x(:$foo) { say $foo};x(|{ (KEY) => 3 })` 14:07
tellable6 dakkar, I'll pass your message to PimDaniel
dakkar m: my constant KEY="foo";sub x(:$foo) { say $foo};x(|{ (KEY) => 3 })
camelia 3
dakkar it's pretty ugly, but I guess it's a weird enough use case 14:08
14:22 kaiwulf joined
codesections dakkar: you could (slightly) beautify that expression by changing the last bit to x |%(KEY, 3) 14:37
dakkar but then it no longer looks like a pair… it's odd either way, though 14:38
codesections fair 14:39
vrurg The ugliness is a way to protect from unexpected behaviors. Just imagine all kinds of 'side effects' if there is a key in the code and a module starts exporting a constant of the same way at some point. 14:54
vrurg doesn't see why a named parameter name should be in a constant? 14:55
dakkar vrurg: I'm not sure, I'm just answering the question ☺ 15:00
vrurg dakkar: not your code? 15:01
dakkar no
I mean, the "solution" is mine, the question was PimDaniel's 15:02
codesections On reflection, I might actually go with `x |(«KEY» => 3)` if faced with this (admittedly very odd!) use case 15:05
Though I'd also give some serious thought to the design decisions that brought me to that point :D
dakkar codesections: that wouldn't do what was requested, though: double quotes (and double angle brackets) don't interpolate sigil-less names 15:14
codesections oh, shoot, you're right. That's what I get for giving the question more reflection without giving it any more testing! 15:20
15:22 linkable6 left, evalable6 left, xelxebar left, xelxebar joined, linkable6 joined 15:24 evalable6 joined 15:35 patrickb left 15:37 patrickb joined 16:04 rindolf joined 16:08 parabolize joined 16:09 sortiz joined
sortiz \o #raku 16:10
16:11 Sgeo joined 16:12 vike left 16:18 jmerelo joined
sortiz codesections: Still interested in cheap tuples? 16:23
16:29 vike joined
summerisle sortiz: i might be 16:31
16:32 PimDaniel joined
sortiz A declarative style subset works 16:32
m: subset XY of List where (Int:D, Int:D); sub pointM(XY \a, Int $e --> XY) { a »*» $e }; pointM (1,2), 3; 16:33
camelia ( no output )
sortiz m: subset XY of List where (Int:D, Int:D); sub pointM(XY \a, Int $e --> XY) { a »*» $e }; say pointM (1,2), 3;
camelia (3 6)
PimDaniel \o again.
tellable6 2021-03-02T14:07:31Z #raku <dakkar> PimDaniel: lizmat: this works, to pass a named argument whose name is in a constant (or any expression, for that matter): `my constant KEY="foo";sub x(:$foo) { say $foo};x(|{ (KEY) => 3 })`
16:34 vike left 16:35 rir joined
PimDaniel I try to use modules.raku.org/dist/Term::ReadKe...an:JKRAMER Module. But i can't really understand how it works. I tried to implement the given example but i cannot seriously capture keys. Are there other real live examples? Thanks. 16:35
16:35 xinming left
jmerelo PimDaniel: did you try to use GitHub search to look for other examples? Or check out the tests? 16:36
PimDaniel jmerelo, NO, i often don't even know where to search. 16:37
16:37 xinming joined
PimDaniel On the other hand, I looked at the module code and i see it uses concepts that i do not know yet like Supplier obj. 16:38
jmerelo PimDaniel: Let me compose the search for you
PimDaniel jemerelo : You'r friendly 16:39
jmerelo PimDaniel: there are a few false positives, but this search returns some of them "in the wild" github.com/search?q=%22use+Term%3A...amp;l=Raku 16:40
PimDaniel:3rd and 4th are definitely Rakulang 16:41
16:41 aindilis left
sortiz summerisle, In particular can be used for complex "returns" constraints. 16:41
PimDaniel jemerelo: ok thank's i'll look at it. My code nearly works but in some situations the loop goes forever so i think my code is bad. 16:42
rir Is there sugar for the transform: ( 0 ^..^1), (2, 3), [4,5] to [ 0,1,2,3,4,5]? 16:43
or a list?
16:44 wamba joined
lizmat 0^..^1 ?? 16:44
m: dd flat ( 0..1), (2, 3), [4,5] 16:45
camelia (0, 1, 2, 3, 4, 5).Seq
jmerelo PimDaniel: It might, but it might also be some misunderstanding in the instructions... or its lack thereof.
lizmat m: dd flat ( 0..1), (2, 3), [4,5] # rir
camelia (0, 1, 2, 3, 4, 5).Seq
PimDaniel jemerelo: for pertinents examples, we would search 'key-pressed' i think. 16:52
16:54 patrickb left
jmerelo PimDaniel: right... Also you might try StackOverflow if everything fails... Either search, or, something that works way better than search, starting to create a question and check out the "related questions" that appear below 16:56
PimDaniel jmerelo: thank you very much, i think i'll be ok! 16:57
16:59 vike joined
jmerelo PimDaniel: sure :-) 17:01
rir Thanks lizmat, now I see a tree in the forest. 17:03
I guess a P5ish prejudice against lists isn't helpful here.
lizmat indeed.... that's one of the false friends 17:04
as is the idea how using a hash instead of a class to get better performance: in Raku, a class is faster, because it can be better optimized 17:05
17:06 PimDaniel left
rir Would that pertain to classes without behavior? 17:06
lizmat you mean something like:
class Point { has $.x; has $.y } vs 17:07
%h<x> and %h<y> ?
rir Yes
lizmat most definitely
github.com/Raku/CCR/blob/main/Rema...-classy.md 17:08
dinner&
rir Nice to know. I don't try to pre-optimize but being efficent by habit is good. 17:09
I'll check the link.
And its sisters 17:10
17:26 rindolf left
andinus how do i make --help|-h print my custom usage text 17:32
its just a few lines appended to $*USAGE
17:38 rindolf joined
andinus hmm & i also have a sub USAGE() it doesnt get called for some reason 17:39
17:41 ufobat__ joined
andinus hmm the docs say they'll get called if no multi candidate of MAIN matches 17:41
so that makes sense
is there a way i can force --help|-h to call USAGE? 17:42
17:45 ufobat_ left 17:47 dakkar left 17:50 berber44 left 17:54 aluaces left
codesections andinus: I'm pretty sure that --help (though not -h) is supposed to call USAGE (and to print it on STDOUT and exit with 0) 18:00
so I'd say it's a bug if it doesn't (imo)
hmm, actually, I'm not sure I'd say that after all. Let me think about that some more... 18:05
but, I do have a way that you can call USAGE:
have MAIN be a multi and add this line: 18:10
multi MAIN(Bool :$help, |) { say &*GENERATE-USAGE(&MAIN) }
evalable6 Usage:
/tmp/bN5G3pCtCe [--help] <Any>
codesections (or GENERATE-USAGE instead of &*GENERATE-USAGE if you defined a custom fn) 18:11
18:19 aborazmeh joined 18:24 aluaces joined 18:33 xinming left, xinming joined 18:36 ufobat__ left 18:46 _jrjsmrtn joined, __jrjsmrtn__ left 18:47 ufobat__ joined 18:59 jmerelo left 19:06 Garbanzo joined 19:09 abraxxa left 19:20 Garbanzo left 19:30 aborazmeh left 19:32 aborazmeh joined 19:33 domidumont left 19:35 Garbanzo joined, xinming left 19:36 xinming joined 19:50 mowcat joined 19:51 wamba left 20:03 eax joined 20:16 brtastic joined, Garbanzo left, Garbanzo joined 20:21 sxmx left, ufobat__ left 20:29 Doc_Holliwood joined 20:38 sxmx joined 20:48 brtastic left 21:03 Doc_Holliwood left 21:06 pounce left, fvox_ left, KotH left, KotH joined 21:07 fvox joined 21:08 pounce joined 21:16 Doc_Holliwood joined 21:18 eax left 21:32 rir left 21:41 xinming left 21:42 xinming joined 21:43 rindolf left 21:54 aborazmeh left 22:10 gugod left 22:17 Doc_Holliwood left, Doc_Holliwould joined
vrurg .tell tyil Trying to get use of Config module. It feels wrong to me that `.read` overrides environment variables; and that there is no way to only read a single custom file with `.new`. 22:26
tellable6 vrurg, I'll pass your message to tyil
tyil vrurg: hmm, I think the second one would be easier to fix than the first in the current way it's working 22:28
to fix the first one, I would need to keep track of which values were gathered from the environment
(doable, for sure, though) 22:29
vrurg tyil: I would make a single method of importing values and use it everywhere. The method then would have support for :from-xdg, and :from-env. It could be read itself. 22:30
And then it could in turn call a private !read-from-file. 22:31
22:32 gugod joined
tyil can you write a small sample of how you would like to use it in that manner? 22:34
might give me a better idea of the interface I could work towards
my current goal with Config is that I never actually need to manually read from additional files, but I can see how that might not be beneficial for everyone 22:35
vrurg What I currently do requries exactly one config in the only posssible location. So, my choice would be Config.new(:$file, :!from-xdg). 22:36
tyil: But it feels to me that something like `$cfg.read($file, :!from-xdg, :from-env)` could also be sometimes useful. Say, somebody would like to update the existing config in the middle of app lifetime. 22:39
tyil yeah, that sounds reasonable
22:39 Discipulus left
tyil I'm contemplating if I should use `:@files` instead of `:$file`, to allow one or more files 22:40
vrurg tyil: the magic words: multi dispatch ;) 22:41
tyil true
I can't make any guarantee on when I have time to add it, but I will add it to my todo list :>
vrurg tyil: Basically, as I looked into the module, I'd introduce a public .read-data method wich would do all the work and return %data. Make it a class method and it would open more ways to use the module. 22:42
So far, I'm anyway at the most early stage of the project. It can certainly wait. 22:44
22:49 kerframil joined 22:52 xinming left 22:53 xinming joined 22:58 xinming left 22:59 xinming joined 23:10 Kaiepi left, Garbanzo left 23:11 Kaiepi joined 23:17 aindilis joined 23:24 Black_Ribbon joined
moon-child is there a more concise way to ensure a regex matches an entire string than putting ^ and $ at the beginning and end? 23:32
MasterDuke i think that's the most concise way 23:47
23:52 agentzh joined, agentzh left, agentzh joined