»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
holyghost I have bettered Game::Bayes but it seems it still has some serious bugs 07:16
antoniogamiz while{ {once {some code}} } and while { some code } has any differences?
holyghost I'm writing a game of risk with risk-o-matic, which takes time
antoniogamiz (notice the extra curly braces surrounding the once block) 07:17
holyghost++
holyghost: what's the theme of the game? 07:18
holyghost a game of risk, the tabletop game 07:19
in a terminal
without ncurses TBH 07:20
antoniogamiz aahhh I had understood it was a game where you must take risks haha 07:24
risk is a very good game
ncurses?
holyghost ncurses/curses, the terminal window and widget set 07:25
risk is perfect for risk functions, although this sounds odd
antoniogamiz yep haha 07:26
holyghost It's a test for Game::Bayes
from rogue-o-matic => risk-o-matic
where rogue is a precessor of nethack
nethack.org
antoniogamiz uoh a little CSS could be used 07:27
holyghost It's an ancient game, I know :-)
antoniogamiz » is that a regex operator? 07:31
moritz » can be used in a regex, and means "right word boundary" 07:42
outside of regexes, it can be used to apply an operation to a list of items
m: say <a b c>».uc.join(', ') 07:43
camelia A, B, C
antoniogamiz thanks moritz! I should look up in the docs before asking this kind of questions
antoniogamiz moritz: what should be the proper subkinds of a routine? 07:46
(I know you did this a long time ago, sorry for asking so many questions) 07:47
moritz antoniogamiz: if a routine exists as just one variant (sub, method, regex), then that 07:48
otherwise, "routine"
iirc
antoniogamiz mmm and are you sure is done like in find-definitions? 07:50
the last part I mean
like that in* 07:51
moritz no, not sure 07:52
antoniogamiz For instance, in Any.pm6 there's only one routine defined as multi sub and multi method, and it gets the subkind "sub" instead of routine
moritz hm 08:21
moritz I'd still say that "routine" would be correct 08:31
antoniogamiz mmm ok :) 08:40
lizmat clickbaits p6weekly.wordpress.com/2019/06/17/...es-of-int/ 08:42
pmurias wheren doing a use chalk:from<node.js> from where should the node.js modules be looked up? 10:28
moritz pmurias from node? I don't quite understand your question. Do you mean from which paths? 10:52
SmokeMachine should it do the same as it would `require("chalk")` on node.js? 12:28
yoleaux 16 Jun 2019 14:45Z <vrurg> SmokeMachine: Sorry, I saw your replies but was preparing/commuting and now attending the conference. Will asnwer ASAP.
lizmat weekly: blogs.perl.org/users/damian_conway/...olset.html
notable6 lizmat, Noted!
vrurg SmokeMachine: I still don't have time to concentrate on the right answer. But I thought that relationship columns are kind of lazy attributes and are fetched upon request. 12:31
lucs Is there a more idiomatic way to say this?: $s.defined && $s.length > 0 13:08
(er, 'chars', not 'length') 13:12
lizmat .defined && .length > 0 with $s 13:14
actually
.length with $s
the "with" takes care of the defined check
lucs Aha, cool :)
Th
lizmat .chars > 0 with $s
yoleaux $ 0 > h i s t w
lucs Thanks 13:15
ugexe if $x.?chars { } 13:28
i guess that doesn't work for some things like native typed vars 13:29
m: my int $x; say $x.chars
camelia 1
ugexe although maybe it does work for you since its defined either way 13:30
pmurias moritz: yes 13:33
moritz pmurias: can't that be configured through environment variables? 13:34
or maybe a "use lib"-like mechanism?
pmurias SmokeMachine: you mean it should look it up relative to the Perl 6 file which has the use statement
moritz: use lib is trash because it screws up precompilation 13:35
ugexe i assumed it would go to $HOME/.npm-global/lib/node_modules
maybe it is possible to avoid recompilation for those cases. like instead of "if any repo id changes re-precompile" do "if any PERL6 repo id changes re-precompile" 13:36
nine: ^ ?
pmurias ugexe: is installing modules globally for use by rakudo.js something that we want to do/encourage? 13:38
ugexe pmurias: it would match what we do for Inline::Perl5 at least
and is what I would expect from inline Perl5 code (not sure what I expect from js)
pmurias ugexe: the issue with matching Inline::Perl5 is that in node.js they handle dependencies a lot differently 13:39
they tend to be installed per project (in a node_modules that's resolved relatively to which file the require is in) 13:40
ugexe per-project dependencies used via `use lib "..."` though 13:41
er, exposed rather
SmokeMachine pmurias: yes... 13:43
ugexe for instance: use lib "js#./ 13:44
if re-precompilation is the only thing stopping you from that then maybe we should see if re-precompilation is required when non-perl6 repos change
pmurias use lib "js#./" ~ $?FILE.IO.parent.add("node_modules"); 13:46
use lib "js#" ~ $?FILE.IO.parent.add("node_modules"); actually
ugexe yea, although better is
use lib "js#" ~ $*PROGRAM.parent.add("node_modules").absolute; 13:47
lucs ugexe: Thanks (re. $x.?chars) 13:48
pmurias ugexe: isn't re-precompilation required if the Perl 6 modules that where precompiled used a js dependency at compile time 13:49
ugexe pmurias: yeah i suppose it would 13:51
antoniogamiz what's the best form of completely flatening an array with sub arrays? 13:54
I have seen the flatenning semicolons in the doc but I think should be another way 13:56
pmurias ugexe: also I think we should aim at being able to specify node.js depedencies in META6.json
do we have a spec for that somewhere?
design.perl6.org/S22.html#META6.json is broken 13:57
ugexe pmurias: no, but we seem to be moving towards just defining them in depends like everything else: "foo:from<node.js>"
pmurias ugexe: I meant a spec for META6.json 14:00
ugexe yes, that is what i mean
same as Perl6 modules
except for Perl6 modules the :from<Perl6> is implied
depends contains "use" strings 14:01
antoniogamiz: if you know the depth of your data structure you can use tree. here is an example that flattens up to 3 levels: @foo.tree(*.Slip, *.Slip, *.Slip) 14:02
pmurias github.com/perl6/specs/blob/master...format.pod - this is the META6.json specification? 14:03
ugexe the META6.json specULATIONs yeah 14:04
i.e. there is obviously no github.com/perl6/specs/blob/master...onlocaltar
pmurias so we have no META6.json spec? :( 14:05
antoniogamiz ugexe: thank you
ugexe the META6.json isn't being designed waterfall style. its being handled in a more... agile manner 14:06
pmurias that's terrible :( 14:07
ugexe that is what happens when you release based on a specific date instead of when something is ready
pmurias (the not having a specification part, not the not waterfall part) 14:08
is anything other from tuits stopping us from having a link to a description of what META6.json actually does in the docs? 14:11
ugexe what it does depends on what is consuming it 14:12
rakudo doesn't care about depends field period
rakudo ultimately cares about name, version, api, auth, provides. thats it 14:14
resources
those things *are* documented 14:15
pmurias so the current situation is that module writers should cargo-cult a META6.json without being able to look up what the fields are supposed to be?
doc.perl6.org/language/modules - that's our module creations docs
docs.npmjs.com/files/package.json - example from node.js how things should be documented 14:16
ugexe if you want to use fields that we have not fully thought out or implemented, then yes you will need to cargo cult. if you are using fields that are fully thought out (and hence likely documentet) then no 14:17
nine ugexe: a repo has full control over its own id. So if a repo does not contain anything that should affect precompilation, the id may just stay constant 14:18
ugexe a repo can affect the id of the repo prior
github.com/rakudo/rakudo/blob/f05b...em.pm6#L43 14:19
pmurias ugexe: if we don't have META6.json documentation nothing is documented 14:20
kawaii timotimo: something reminded me, I never got a chance to try your patch
timotimo: can you link me the gist again please Sir? :)
ugexe pmurias: but it is documented on the page you linked 14:21
maybe not in the format you like, but it describes the fields that rakudo understands
pmurias ugexe: you mean in doc.perl6.org/language/modules?
ugexe yes 14:22
nadim_ afternoon, how do I get a method (taking args) reference and call it? is it documented with a simple example somewhere? 14:25
ugexe pmurias: also im not familiar enough with js to say for sure, but is that spec specific to npm? if i create an alternative installer (yarn, etc) and add custom fields is that part of the spec too?
moritz m: my $method = 4.find_method('sqrt'); say $method(9) 14:26
camelia No such method 'find_method' for invocant of type 'Int'
in block <unit> at <tmp> line 1
moritz m: my $method = 4.^find_method('sqrt'); say $method(9)
camelia 3
moritz nadim_: ^^
nadim_ moritz++
moritz note that the method is not curried (so not tied to the invocant)
m: my $method = 4.^find_method('sqrt').assuming(4); say $method() 14:27
camelia 2
nadim_ so it needs to be called with an object, right? I need to decided between two methods when I am inside a method (to avoid code duplication) 14:28
moritz: did you reallly mean _not_ tied to the invoquant? 14:29
moritz yes
you can see that I call $method(9), where 9 is the invocant 14:30
compared by pthon's method = obj.methodname; method()
where method contains a reference to obj right away
nadim_ but the example you called gave 2 as an answer when it was called without argument
moritz that's because of the extra .assuming(4) step
which does the currying 14:31
nadim_ ok
moritz sorry, too much information at once is not always helpful :D 14:31
nadim_ not too much, it was two examples and I thought the first comment was aout the second example :) 14:32
moritz: what's the difference betwen ^find and ^lookup?
pmurias ugexe: what's stopping taking an already implemented by zef subset of the META6.json speculations and using it as description of how things are?
moritz nadim_: I don't remember the specifics; I think it has something to do with roles, where .^lookup returns something subtly different or so 14:35
I'm sure jnthn++ knows
docs.perl6.org/routine/lookup "Note that lookup is supposed to be used for introspection, if you're after something which can be invoked you probably want to use find_method instead." 14:36
that's good enough for me right now
nadim_ the only answer, with details, I found was this stackoverflow.com/questions/480803...in-perl-6, an example in the docs would be nice 14:37
tobs m: my $meth = 4.^find_method('sqrt'); say 25.$meth # do you take sugar? 14:39
camelia 5
moritz
.oO( $meth heads all around :D )
14:42
pmurias nadim_: I looked at lookup source
nadim_: and it behaves differently with submethods (it finds submethods from parent classes) 14:43
moritz m: role R[A] {method x() { }}; say R.^lookup('x'); say R.^find_method('x') 14:44
camelia 5===SORRY!5=== Error while compiling <tmp>
Invalid typename 'A' in parameter declaration.
at <tmp>:1
------> 3role R[A7⏏5] {method x() { }}; say R.^lookup('x');
moritz m: role R[$A] {method x() { }}; say R.^lookup('x'); say R.^find_method('x') 14:45
camelia x
No appropriate parametric role variant available for 'R'
in block <unit> at <tmp> line 1
moritz that's the difference I was thinking of
pmurias nadim_: and when there is a FALLBACK lookup finds nothings while find_method returns the fallback
nadim_ pmurias++ 14:46
pmurias nadim_: honestly the submethod difference looks like just a bug 14:47
pmurias nine: is there a way from CompUnit::Repository to load stuff relative to the file where the 'use statement' is in? 14:48
nine pmurias: now, that just doesn't sound right 14:53
pmurias nine: I thinking about replicating the node.js module finding semantics: nodejs.org/api/modules.html#module...es_folders 14:59
nine: but this seems like mixing up the Perl 6 and node.js ways of doing stuff together in a horrible manner 15:00
daxim ᴞ # help, I've fallen and can't get up 15:02
pmurias btw what's the state of the Perl 6 docs google summer of code projects
afk & # will backlock 15:03
nine pmurias: I think it'd be ok for us to require the user to add the repos with -I or use lib. 15:06
timotimo kawaii: gist.github.com/timo/b5fedaf5bea40...57addb25d0 15:32
kawaii ah! thank you!
lizmat weekly: www.youtube.com/channel/UC7y4qaRSb...8cCHOsKZDw 16:10
notable6 lizmat, Noted!
lizmat Video of TCPiP
ugexe pmurias: we could, i guess. but there are still details that exist now but probably shouldnt 16:16
like depends can have either a module name or a distribution name. that exists right now, but maybe it shouldnt 16:17
if we document it then its even harder to fix/change later
if someone wanted to write a document for it i could review it and say what should be left out. 16:18
however i am mostly incapable of writing that document myself because i get bogged down in the endless details i have in my head 16:19
El_Che lo 16:22
lizmat: are you in the US? 16:32
Geth doc: 7ad9cd108f | (Moritz Lenz)++ | doc/Type/Metamodel/MethodContainer.pod6
Document difference between find_method and lookup
16:36
synopsebot Link: doc.perl6.org/type/Metamodel::MethodContainer
lizmat El_Che: no 16:48
lizmat will not visit the US until the orange blob is gone, and possibly not after that either
El_Che yeah, I have a similar feeling 16:52
nadim_ lizmat++ 17:02
timotimo: (other are welcome with an opinion too of course) I implemented coloring per level in DDT, it's a different way to present data, I put some examples here distracted-gates-4eb889.netlify.com/ 17:04
It's a larger patch, not sure I include it or not
timotimo nadim_: i would prefer more muted colors, but it does seem helpful for very big things 17:09
nadim_ you get to chose your color of course :) 17:12
timotimo i assumed so d) 17:13
:)
nadim_ rendering a christmas tree is of no help but you can control what gets colored or not, in the example it is by level but you can chose to highlight classes or specific instances
timotimo that's how i interpreted the later examples
nadim_ but thiis mode is for rendering with :!color, as you can see in the last examples the color rendering stops the background coloring, because it makes little sense 17:15
timotimo yeah, that could turn out pretty unreadable
nadim_ I actually wrote this for very large rendering where only a few pieces are important 17:17
timotimo ah, yeah, i can see how that would be useful 17:18
i wonder how complicated it is to write something in js that when scrolling downwards will pin the pieces of the tree that make up the path towards the root to the top 17:19
inspired by twitter.com/jckarter/status/1140131108564062213 and the "frame editor" further below in that thread
nadim_ timotimo: that's cool. the latest DDT has a flatten example where the path is added and the elements are rendered separated with tabs so you can use a bash pipeline on the data structure 17:23
timotimo yes, i remember! 17:26
nadim_ timotimo: pinning up the part of the tree could be made quite easy if the path is put in the html for each entry so you can display it or have a have a popup display it 17:30
if you need it, and write the part that display the path in the web page (I suck at this stuff), I'll add the path to the generated html 17:35
timotimo i should concentrate on other stuff at the moment :( 17:37
nadim_ sure :) just say if you need it and help with it 17:38
timotimo thanks :) 17:39
nadim_ thank you for the feedback
timotimo NP 17:41
guifa Well that was a ridiculously easy code golf 17:53
codegolf.stackexchange.com/a/187050/30284
Geth ¦ problem-solving: AlexDaniel assigned to jnthn Issue require with non-sigiled arguments github.com/perl6/problem-solving/issues/43 18:43
AlexDaniel guifa: I'm not satisfied with its performance though :) 19:43
guifa: .comb.unique.permutations in numeric context shouldn't even generate any elements, I think
Elronnd is there a way to block until *one* item is available from a supply? 19:44
AlexDaniel and there is a mathy way to make the answer right, I think
Elronnd: not sure, but what about .Channel.receive ? 19:45
lizmat Elronnd: make sure the first item on a supply is a Promise, and await that ? 19:45
Elronnd AlexDaniel: I think that would work 19:46
AlexDaniel Elronnd: also maybe `react whenever $supply { …; done }`
guifa AlexDaniel: I don’t follow. The numeric context applies to the result of the *.comb.etc. It gets parsed as (+) (*.comb.etc) which is similar to +@foo.list-ops, where @foo.list-ops is evaluted first, and then numified: 20:09
p6: my @a = <a b b>; say +@a.permutations
camelia 6
AlexDaniel guifa: yes but for permutations».join.unique you'll actually need to generate all permutations and keep them in memory
timotimo Elronnd: i think you can $supply.head actually?
guifa AlexDaniel: sure, but it’s code golf. Who cares about performance? :-) 20:10
AlexDaniel guifa: yes :)
though I'd also like to see a golfed version that actually works for bigger strings :)
guifa There’s a formula, which is probably the best next option. I tried golfing it to P6 but it was longer 20:11
AlexDaniel “permutations” is a really long word, however, maybe avoiding the builtin is a way to go…
guifa: speaking of code golf, have you tried code-golf.io/ ? 20:12
guifa: also there's github.com/AlexDaniel/raku-golf-cheatsheet
guifa Actually I just realized that .Set can be shorter than .unique and accomplish the same. 20:16
timotimo true. if you just need the number, that's the same. otherwise you'd need .Set.keys to get the same thing 20:18
guifa I just need the number so ha. 20:22
timotimo m: say +(1, 2, 3,4) .perl 20:24
camelia 4
timotimo m: say +(1, 2, 3,4).perl
camelia Cannot convert string to number: base-10 number must begin with valid digits or '.' in '3⏏5(1, 2, 3, 4)' (indicated by ⏏)
in block <unit> at <tmp> line 1
timotimo ^- cool trick
guifa Although does make me think, surely there’s quite a few common combinations of methods that could be optimized (like the .permutations.unique). Would there be a way to potentially capture that and override with a more efficient method? 20:25
timotimo hm. so it'd want to first build a Bag and treat things that are in there multiple times as the same value 20:26
though .Bag doesn't allow the same parameters as .unique
surely there's some smart algorithm for this case 20:31
tobs m: ('A' .. 'z').permutations.elems.say 20:32
camelia Cowardly refusing to permutate more than 20 elements, tried 58
in block <unit> at <tmp> line 1
guifa Ha! 20:33
tobs so this could use a PredictiveIterator or how it's called
but .unique…
timotimo PredictiveIterator is for when .elems can be done very easily, yeah
tobs sounds like a fun project going through the builtins and spotting predictable iterators 20:34
guifa It feels like there ought to be some way to let .permutations be both lazy and hoarder-less, and pass its values one by one to unique, but not needing to store them. Kinda…sounds like a channel lol. And yet I can’t think how that would work in practice 20:37
tobs huh, that coward error is in the CORE.setting
timotimo unique will still need to store stuff 20:38
worst case, the exact same amount that .permutations.eager would
lizmat m: dd +<a b c b a>.Set # guifa 20:47
camelia 3
guifa @lizmat that’s what I’m using now :-)
guifa I think the issue is that .permutations at some point must store all of it in memory at once. But if we know we’re going to eventually grep/unique/whatever it (and permutations can be deterministically generated, e.g., given fully predictable determinative), it seems silly to generate and store all of them in memory. A lazy list could prevent needing to get all of the permutations until used, but wouldn’t get rid of the memory issue. 20:50
(not that this is unique to P6 at all)
pmurias do we have something like Carton for Perl 6? 20:58
pmurias nine: I guess -I will have to do 20:59
pmurias nine: I don't feel like recommending 'use lib' as it seems to be very harmful garbage 20:59
pmurias nine: as it both kill precompilation and takes paths relative to the current working directory by default 21:01
tobs guifa: the permutations are lazily produced already and apparently the iterator is even predictive already. It's just that there is a `die` blocking you from passing arguments which are too large for a certain native int counter used in the algorithm. 21:07
MasterDuke lizmat: still around? 21:14
lizmat MasterDuke: not really 21:45
MasterDuke heh. then i'll ping later 21:46