🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
justsomeguy Does raku have something like pyenv+poetry (a build chain manager, and project-specific build tool that tracks dependencies and runs things in isolation of the system-wide build chain)? 00:05
summerisle leont: Str literal and .encode 00:17
buf literals would be neat 00:18
leont Yeah, that's what I'm currently doing
Though that doesn't always play well with is-deeply (because that returns a utf8, not a buf8)
summerisle i've just discovered the library i want to bind to uses templates.
summerisle dies
c++ is a cursed language 00:19
leont And I haven't seen a way to convert one to the other
leont worked in C++ until a few months ago
summerisle glad you got out
leont A lot of things are nice about it TBH, but it doesn't play along with other languages much
summerisle there are the nice bits but they are totally obscured by the problems imo 00:20
i wish it wouldn't use C calling conventions by default so that people would be forced to provide sane interfaces 00:21
instead of saying "just use the C++ interface from another language lol"
so now i probably need to write a bunch of glue 00:22
ah, and of course taglib has its own string wrapper as well 00:24
how nice
i wonder, does the C++ support in nativecall even make sure to call destructors? 00:26
surely
leont The whole idea of nativecall kind of falls flat with C++, IMO 00:31
C++ hates FFI
The other way around generally works better IME, letting C++ templates write the bindings to another language. It's also a way to lose sanity points :-p 00:36
moon-child yeah nativecall c++ is not really a sensible idea 01:08
it barely works in d, and d is very similar to c++. Even after they changed some language features to make it align more closely with c++ it doesn't really work 01:09
moon-child why are there both constant Empty and no-argument slip? 04:02
fluca1978 is there a smart way that allows me to process an array using sequentially adiacent elements, without having to use a for or a similar iteration? I mean for 0 ..^ @a.elems { # get $_, $_ + 1 and so on } 08:15
moon-child rotor 08:16
fluca1978 using map only allows me to get "couples", such as @a.map: { $^a, $^b } at every iteration
moon-child m: .say for <a b c d e>.rotor(2 => -1) 08:17
camelia (a b)
(b c)
(c d)
(d e)
fluca1978 moon-child: I didn't know the => -1 trick 08:18
moon-child k is batchsize, v is step. So -1 means step back by 1
tbrowder hi, anyone interested in continuing discussion of Dateatime? 10:52
*DateTime
moritz_ DateTeaTime? :D 10:59
tbrowder .tell lizmat i see that Dateish daycount is almost what is needed. except the MJD is correctly a Real number with the fractional part being the time of day as a fraction of 24 hours.
tellable6 tbrowder, I'll pass your message to lizmat
moritz_ that reeks of loss of precision 11:00
tbrowder Ttime is also an alias for cocktail hour ;-D
lizmat tbrowder: so, if I understand correctly, you would need a DateTime.from-julian-date method that would create a DateTime object using some value mangling 11:02
you wouldn't need an extra attribute for that, would you ?
tbrowder no i don't think so
lizmat then I'd say: make a PR for that method :-) 11:03
PimDaniel o/ 11:04
How do we implement process in constructors?
tbrowder ok, i'm on it. thnx, lizmat 11:05
PimDaniel If we create/overload a new method, we can't modify any parameter at this step : so what can we do?
lizmat PimDaniel: maybe you need a TWEAK method ? 11:06
PimDaniel lizmat : TWEAK?????
is it an expression or something existing into Raku?
lizmat docs.raku.org/language/objects#ind...ntry-TWEAK 11:07
PimDaniel Ok i look at this... thank's...
lizmat m: class A { has $.foo; method TWEAK() { $!foo = $!foo + 42 } }; say A.new(foo => 0).foo 11:08
camelia 42
lizmat m: class A { has $.foo; method TWEAK(:$bar) { $!foo = $bar + 42 } }; say A.new(bar => 21).foo 11:09
camelia 63
lizmat PimDaniel ^^ two common uses of TWEAK
PimDaniel i wonder why i did not see that : i see BUILD everywhere and it does NOT, respond to my needs. I think reference is NOT very clear for this. 11:13
lizmat PimDaniel: yeah, that section suffers from having been written *before* TWEAK was introduced into the language
tadzik 3> If we create/overload a new method, we can't modify any parameter at this step 11:14
yes you can :)
PimDaniel BUILD forces me to pass all attributes from previous new overloaded subs.
tadzik the BUILD/TWEAK confusion is what made me less afraid of overloading new() (and understanding it better)
it also removes the temptation to add an attribute when what you really want is a constructor parameter 11:15
lizmat also, nowadays you can have public attributes that don't build, and private attributes that do :-)
$.foo is built(False)
PimDaniel tadzik : NO you can't modify an attribute $! into a new method.
lizmat $!bar is built
tadzik PimDaniel: I'm not suggesting to modify an attribute 11:16
but you said "modify any *parameter*"
you can then *set* the attribute to the right value in the first place
PimDaniel Even to attrib it in any case: try it.
tadzik that's the sane way to do it
PimDaniel parameter attribute like you want : a class variable. 11:17
tadzik parameters and attributes are completely distinct things, that's my point
TWEAK encourages you to treat them as one which is an awful idea
PimDaniel into a constructor : you cannot touch attributes of a class.
because they don't exist before bless 11:18
tadzik m: class A { has $.b; sub new (%args) { self.bless(*, b => $args<b> * 2) } }; A.new(b=> 5).b.say
camelia 5===SORRY!5===
'self' used where no object is available
at <tmp>:1
------> 3class A { has $.b; sub new (%args) {7⏏5 self.bless(*, b => $args<b> * 2) } }; A
Variable '$args' is not declared. Did you mean '%args'?
at <tmp>:1
-----…
tadzik I'm not suggesting to touch attributes in new
m: class A { has $.b; method new (%args) { self.bless(*, b => %args<b> * 2) } }; A.new(b=> 5).b.say # too much Perl
camelia Too few positionals passed; expected 2 arguments but got 1
in method new at <tmp> line 1
in block <unit> at <tmp> line 1
tadzik argh
too much Perl Episode Two 11:19
m: class A { has $.b; method new (%*args) { self.bless(*, b => %args<b> * 2) } }; A.new(b=> 5).b.say # fingers crossed
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '%args' is not declared. Did you mean '%*args'?
at <tmp>:1
------> 3ethod new (%*args) { self.bless(*, b => 7⏏5%args<b> * 2) } }; A.new(b=> 5).b.say #
tadzik I should've tried it somewhere else first
PimDaniel Well i think i should say attribute instead of parameter : parameters are for subs and methods. 11:20
tadzik it's my pet peeve so I may assume too much, but imho in the overwhelming majority of the cases you need TWEAK because you treat your attributes as if they were constructor parameters 11:21
m: class A { has $.b; method new (*%args) { self.bless(b => %args<b> * 2) } }; A.new(b=>5).b.say # this finally works 11:22
camelia 10
tadzik if you want to modify new()'s input data to build your object, it makes the most sense to do it in new() imo
otherwise you end up defining the structure *and* the interface of your objects because of you want your new() to look like, basically 11:23
PimDaniel of course, we may modify constructor parameters and make process before bless but it is often weird because you'll need to attrib them afterward to class attributes.
tadzik I think it's less weird than defining attributes that you don't need just to influence new()'s behaviour 11:24
PimDaniel I have about 10 constructors to change since i know TWEAK().
tadzik if you're interested in my rationale for this, here's my talk about this whole thing: www.youtube.com/watch?v=783CBT1r1DU 11:25
PimDaniel Suppose you have a $!flag attribute:
tadzik It's about Moose mostly, but Raku suffers from the same design problem imo
PimDaniel This flag is a multi-bit action rised: common in C. 11:26
If you need to rise a bit flag : you need process and it is really heavy to NOT act directly on the $!flag attribute itsef. 11:27
Suppose the flag has 60 actions! 11:28
tadzik yeah, I get you
PimDaniel You can't do that into new, well you can but it will not be optimized. 11:29
tadzik ...why? 11:30
what's the difference between doing it in new() vs TWEAK?
it's a method call either way
tbrowder lizmat: back on the jd thing, i was thinking of mangling the DateTime.new(Str,...). is that what you had in mind?
tadzik I may be misunderstanding what you're trying to do, but my impression was that you want to turn what the user gives you in new() into something that's actually useful for your object 11:31
PimDaniel because often some process may be done as well during construction that after construction.
lizmat tbrowder: no, I was thinking of adding a method ".from-julian-date"
tadzik you wanted to implement processing in constructors. I suggest you to actually implement processing in a constructor
lizmat tbrowder: *not* new
tadzik sometimes you do need to do something after the construction, yes. That's what TWEAK is for. But this is for doing something on an *object*, and you asked about parameters and how to adjust them, if I remember correctly 11:32
PimDaniel tadzik : no my problem is not parameter, but class variables or attributes if you prefer. 11:33
tadzik okay, again, what are you trying to do exactly? :) 11:34
PimDaniel Exactly what i said: valorizate a bit flag : before and during construction.
tadzik why do you need to do it twice? 11:35
PimDaniel So i've a method setflag which makes : method setflag(Str $f) { $!flags = $!flags +| ::($f); + more process;} 11:37
Now i cannot call setflag into a new sub which allready exists 11:38
and YES i can attrib $!flags directly into my constructor be i'll have to make the process externally which is weird. 11:39
So i'll try TWEAK ... thank's for you help lizmat and tadzik. 11:42
tbrowder um, i'm not sure that's worth the effort. i can just as easily go back to having a DateTime attr in my "subclass"
i'll have to think about my real use cases a bit more 11:44
lizmat tbrowder: so what extra functionality should an object made with DateTime.from-julian-date(...) have ?
tbrowder outputs: juliandate, mjd 11:45
tbrowder but just by allowing the subclass to TWEAK DateTime parent's y,m,d,h,m,s would do the trick. then moi, the user, could add all the tricks i want at no xtra cost to anyone else 11:48
lizmat tbrowder: you mean the .Str / .gist / .raku output should be different
Doc_Holliwood m: say -Inf + Inf 11:50
camelia NaN
Doc_Holliwood m: say (-Inf) + Inf
camelia NaN
lizmat_ class JulianDate is DateTime { method new(...) { self.DateTime::new(...) } }
tbrowder ^^
tbrowder hm, i'll give that a shot. remember in my defense to guifa2 i said that fancy construction techniques over my pay grade were needed! 11:53
Doc_Holliwood found a reason to use base-repeating =) 11:53
twitter.com/HrBollermann/status/13...7091833866
Doc_Holliwood i had no idea the function exists but I found it within a minute 11:54
speaks for the docs methinks
tbrowder lizmat: i will report back, thanks!
m6locks_ might want to check the rakudo star build instructions 12:13
I can't find a Configure.pl in the rakudo dir after extracting the tarball
should I just cd into the src dirs and build rakudo, nqp and moarvm separately? 12:14
lizmat tyil ^^
tyil oh 12:15
m6locks_: download the tarbal, `./bin/rstar install`
or check the README.md
m6locks_ ok thx
building now 12:16
hmm build failed 12:17
cannot determine the brand of your make utility 12:18
this is on dragonflybsd
tyil I have never even heard of dragonflybsd 12:23
so that might be related :p
I'm also not at home, so I don't have a machine to slap a VM on to try it out with either
m6locks_: do you have default compilation tools installed?
think gcc and make 12:24
m6locks_ yes
I just built firefox and chrome from ports sources 12:26
tyil m6locks_: can you post the output of `./bin/rstar sysinfo` 12:30
m6locks_ aye 12:31
./bin/rstar sysinfo
version 5.8-release
term xterm-256color
key dragonfly
os dragonfly
arch x86_64
tyil ok 12:32
can you try this tarball dist.tyil.nl/raku/star/rakudo-star...sd1.tar.gz
(and post output of sysinfo again)
m6locks_ downloading 12:33
tyil also, you can run `./bin/rstar sysinfo | nc tyil.nl 9999` to only have to post a link to the channel 12:34
m6locks_ p.tyil.nl/s61h 12:35
tyil that looks good 12:36
you can retry building it from that tarball (dist.tyil.nl/raku/star/rakudo-star...tar.gz.asc for the PGP sig, if you want to verify it)
m6locks_ aye trying it now
tyil if it doesn't work, I'll sadly have to try something tomorrow on a VM at home 12:37
m6locks_ yes
tbrowder .tell lizmat it looks promising...continuing to flesh out details
tellable6 tbrowder, I'll pass your message to lizmat
lizmat cool 12:38
tyil m6locks_: is the lack of news a sign of good news? 12:57
tbrowder ok, i can round trip the juliandate inside/outside the subclass okay, but it looks like my to/from algorithm needs a leetle work. :-( 13:25
m6locks_ tyil: ah sorry no, it failed with the same error 13:27
I'm not sure if it's related to the locale warning where bash is complaining about LC_ALL that cannot be changed (C.UTF-8) 13:29
but in any case it's not building
tyil ah 13:38
well, I'll have to try tomorrow then
PimDaniel o/ 14:03
How to put down binary flag?
I try -^ but it does not work as expected :( 14:04
started with -| but it's worth.
I can't see clear informations into reference about this or like it is often the case we don't know where to search. 14:05
ugexe docs.raku.org/language/operators#infix_+^ 14:07
there is the docs for similar ops
and docs.raku.org/language/operators#prefix_+^ 14:08
summerisle cperl-mode is wild 14:14
at the implementation level
(yes, i'm back at it with raku-mode)
codesections summerisle++ 14:15
PimDaniel ugexe saw that many times. thank's.
codesections which bit are you improving now?
PimDaniel ugexe i want to put down one bit and the behavior is strange 14:17
summerisle i was losing sleep last night over the idea of completely scrapping SMIE and implementing a (better than SMIE, at least) lexer 14:18
PimDaniel m: (0 -^ 0b0100).raku.say
camelia -4
PimDaniel why that?
m: (0 -^ 0b0100).base(2).say 14:19
camelia -100
summerisle and as such i was looking at how cperl-mode had gone about things because if memory serves it does exactly that
it is also a 6k+ LOC single-file emacs module
with various levels of formatting quality...
i found a comment in the perldb section about some hack to make it work with OS/2 14:20
PimDaniel I did NOT expect to have negative values! What does this mean?
summerisle i don't even know who is editing perl in emacs on OS/2
codesections summerisle: wow
summerisle unless i'm missing some overlapping terminology i.imgur.com/5r73yAq.png
wow, cperl-find-pods-heres is quite the chunky lad 14:23
i think (i hope) there is too much weird p5 cruft here to really take much away... 14:24
when the code to find POD and heredoc spans 1k loc... 14:25
codesections tangent: my dream version of raku-mode would integrate heredocs with polymode or similar, so that I could write something like my $markdown = to:/§md/; and then get markdown syntax highlighting for the heredoc 14:29
MasterDuke m: (0b1100 +^ 0b0100).base(2).raku.say # PimDaniel is this what you wanted?
camelia "1000"
codesections s/to ':'/q:to/ 14:30
codesections spent too long deciding whether to add the single-quotes in that s/// 14:31
PimDaniel Well to resume i can rise a bit flag value this way : $flags = ($flag +| $f); but how can i put the flag down? :( thank's. 14:46
* Well to resume i can rise a bit flag value this way : $flags = ($flags +| $f); but how can i put the flag down? :( thank's. 14:47
MasterDuke docs.raku.org/language/operators#infix_+& right? OR is for setting flags, AND is for clearing them 14:51
PimDaniel Thank's MasterDuke but how can +& put down my bit flag? 14:55
let's say i have 0b0010000; and want to lower only rised bit? 14:57
*raised
The only solution with +& would be to use the binary complement of the mask. 14:58
but i thought there were a simpler solution. 14:59
SmokeMachine Have anyone ever suggested using IPFS to host Raku modules? 15:04
summerisle that's an interesting idea. i need to check out ipfs again. last i used it, it was very slow 15:05
but that was when it first became a thing
SmokeMachine I’ve been testing it recently (I just discovered about that last week) and it’s not seeming slow… 15:07
summerisle that's good to hear 15:09
i must have used it as early as 2014 if it was around then, if not then 2016
2015 then
xinming_ IPFS module hosting + 1 15:22
it depends on the nodes
tonyo smokemachine, anything wrong with the fez setup? 15:46
SmokeMachine tonyo: not at all! I just thought that could be one more possibility. 15:48
tonyo: I thought it would be cool to have the modules distributed in a distributed fashion... :) 15:49
ugexe storing isnt a real issue, its recommendation / consensus engines
IPFS does nothing for that, it just another backend for them to use 15:50
tonyo the fez one is distributed : ) 15:57
kleb hi folks! is there any way to use raku regex (in a grammar) to match on permutations or combinations of a set of rules? 16:17
for example, if i wanted to be able to match "static inline friend" "friend inline static" "friend static inline" "static friend" "inline friend", etc but nothing like "static static static" 16:18
kleb something like:               [ 'static' | 'inline' | 'friend' ] ** 2..3 16:21
though i want to ignore when there are duplicates
codesections hmm, interesting question 16:23
tonyo yes 16:25
tonyo you'd want to use a method to control what's available to match 16:26
or, you can, rather
tonyo docs.raku.org/language/grammars#Me...n_grammars 16:27
kleb oh, bingo -- thank you! i know how to figure it out now.  that is an awesome feature
wow
that makes so many more things possible :)
just clicked 16:28
codesections docs.raku.org/language/regexes#Rec...ve_Regexes might also be helpful here, I'm not positive 16:28
kleb thanks everybody! 16:32
PimDaniel I'v found it myself; i forgoted i had to make the complement to low down a bit. $!flags = $!flags +& ( $mask +^ 255); to lower down a bit. for a 8 bits wide $flags. 17:37
may be $!flags +&= would work too. 17:38
It should be better to express things in binaray : $!flags = $!flags +& ( $mask +^ 0b11111111); 17:39
tonyo a roll helps that readability without requiring you to fully write out binary .. $!flags +&= 1 <+ (whatever bit you want to set); 17:42
PimDaniel Yesss tonyo i mentionned it at 19:38 17:44
thank's anyway!
i'll earn 7 chars at each line. 17:45
tonyo that should be +<, not <+ 17:46
you getting paid by the char?
PimDaniel Yess true binary operators changed and we must care about syntax when we start. 17:47
I mean changed compare to Perl5
El_Che s/Perl5/Perl/
PimDaniel El_Che: Non non non! 17:48
El_Che non,non,non, rien a changé
?
PimDaniel Yé né pas changé, non : je suis toujours aussi empoté. 17:49
who codes in Perl4? hum? 17:50
and Perl1/2/3. :/
kurahaupo PimDaniel: I very occasionally find p4 in embedded systems firmware that hasn't been updated in 20 years 17:51
Even then, it's usually p4 scripts running on p5.002 or somesuch
PimDaniel What Operating System? 17:52
I do not even know when perl4 was running.
kurahaupo 1994-ish
PimDaniel Hum ok. 17:53
kurahaupo Usually as perl-cgi running the embedded web server on some router
PimDaniel Yess i undestand. 17:54
kurahaupo The "if it ain't broke don't fix it" mentality is pretty strong in the hardware OEM community
PimDaniel This is nearly software part of hardware. 17:55
In 1994 there were still many non-oses embedded systems.
kurahaupo PimDaniel: Êtes vous français(e)?
PimDaniel But you are true. 17:56
Ouais chui français mais juste parce qu'il faut bien être quelque-chose.
PimDaniel kurahaupo : sorry i must leave. See you later. 17:57
tyil m6locks_: I installed dragonflybsd on a vm, but it doesn't appear to even have a network connection by default 19:47
`/etc/rc.d/dhcpcd status` doesn't show anything, and exitcode is 0 19:48
so I'm not gonna be able to even get started on reproducing the issue 19:49
lizmat
.oO( at least it's secure :-)
tyil I mean, I guess 19:50
tyil FreeBSD just works, and OpenBSD works more often than not (though it's a close call), but I don't seem to have anywhere near a usable system with DragonflyBSD 19:51
tyil and it's late, so I don't really wanna get too deep into it right now 19:51
m6locks_ tyil: if you have intel drivers you can create the interface 19:52
aye
tyil I'm on a vm
I was hoping to not have to hunt random drivers just to get basic internet working :p
m6locks_ sudo kldload if_iwm && sudo ifconfig wlan0 create wlandev iwm0
tyil wlan?
on a vm?
m6locks_ well if you don't see the wlan0 interface there you won't have a network connection 19:53
tyil I think it's better to discuss this in pm, so as to not flood the channel with DragonflyBSD troubleshooting :>
m6locks_ aye
japhb considers Conservation of Bugs in relation to freehanding 4 modules and finding only one (thinko) syntax error ... the semantic mistakes are going to be BRUTAL, I can just feel it. 21:09
lizmat and another Rakudo Weekly News hits the Net: rakudoweekly.blog/2021/03/29/2021-13-games-pop/ 21:20
sxmx since rakudo (targeted|targets) jvm, would it be possible to bring raku to grail? 21:35
MasterDuke sxmx: there is a work-in-rather-slow-progress to do so 21:37
well, not just graal, but implemented with truffle. github.com/Raku/nqp/tree/truffle
sxmx cool thanks. just a thought that popped into my head 21:48
has anything run yet or is it still too early> 21:50
MasterDuke iirc, it can run some nqp code (and with very specific examples it can be faster than both the existing jvm backend and moarvm), but not all, so no rakudo code 21:53
i think github.com/Raku/nqp/blob/truffle/s...sts.pl#L12 shows the nqp tests that pass 21:55
sxmx That'd be cool if that becomes usable. I like the language, but the performance is less than great on my openbsd vps 22:00
lizmat fwiw, which version of Rakudo are you using ?
sxmx it's taking about two and a half minutes to regex search the words file 22:01
MasterDuke unfortunately regexes/grammars are about the least optimized part of rakudo right now
sxmx I'm using 2021.02.1 from packages 22:02
6.9 snapshot
lizmat ok, so you're up to date, good to hear! 22:05
so OOC what is the regex you use on words ??
sxmx just something like /^rhy.*$/ finding words with certain clusters 22:07
lizmat sxmx : then try "words".IO.lines.grep: *.starts-with("rhy") 22:08
sxmx so string methods instead? 22:12
codesections sxmx: also, when you do need a regex but don't need to backtrack, the :ratchet setting can help performance a lot (so, rx:r/…/ instead of /…/ ) 22:14
also -- and you probably know this but it's a common enough issue to be worth mentioning anyway -- $ matches the end of the _input_ rather than the end of the line ($$ is the end of the line). 22:23
Doc_Holliwood m: say (1..Inf).reverse.first 22:57
camelia Inf
Doc_Holliwood well play #raku. well played
codesections m: say (1..∞).reverse.head(2) 23:01
camelia (Inf Inf)
moon-child haha, that's amazing 23:11