🦋 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.
00:26 dogbert17 joined 00:30 AlexDani` joined 00:32 AlexDaniel left 00:40 jaldhar_ left, jaldhar_ joined 00:57 AlexDani` left 01:04 jaldhar_ left, jaldhar_ joined 01:07 Tirifto left 01:08 wildtrees left
SmokeMachine xinming_: I continue playing with json: www.irccloud.com/pastebin/SWYIMqeE/ 01:24
Xliff SmokeMachine: After taking a while to look at it, I get it. That's pretty good! 01:32
I just don't know if I like the use of .^all in some of those situations.
How would it look if I only wanted to set a subset of rows to a specific value?
SmokeMachine Xliff: :)
Xliff: what situations do you mean?
Xliff Like.... setting .num1.foo[$bar] = 'ber' for all rows where num2 == 42 01:33
Assume $bar is an int 01:34
You'd probably use ^all.grep ?
^all.grep.map(...).save ?
Have you thought about making a .^where alias that basically does .^all.grep ? 01:35
SmokeMachine Xliff: yes... 01:40
Xliff: no... but what do you think `.^where` would be better than `.^all.grep`? 01:41
01:41 cpan-raku left 01:43 Zachac joined
Xliff Why do I think .^where is better than .^all.grep? It's easier to remember for new users 01:46
I'm not saying to use this in place of.... I'm saying that it could be an alias to make it more attractive to...folks that it would be more attractive to. 01:47
Like me.
01:47 cpan-raku joined, cpan-raku left, cpan-raku joined
Xliff I get .^all.grep -- but I think most people would prefer .^where. 01:48
01:48 jaldhar_ left, jaldhar_ joined
SmokeMachine Xliff: I think easier to the user, if the don't like the `.^all`, could be if the do: `my @rows := MyModel.^all` at the beginning of the code, and then could use: `@rows.grep(...)` 01:49
ZzZombo m: 42 ~~ :say 01:50
camelia 42
Xliff SmokeMachine: OK, so why not give it to them as an alias. TIMTOWTDI
Most new users won't know enough perl6 to even think of doing 'my @rows := MyModel.^all' 01:51
ZzZombo Why was that added into Raku though? for
m: 42 ~~ :goawayanddie
camelia No such method 'goawayanddie' for invocant of type 'Int'
Did you try to smartmatch against a Pair specifically? If so, then the
key of the Pair should be a valid method name, not 'goawayanddie'.
in block <unit> at <tmp> line 1
SmokeMachine Xliff: (I don't think most people would prefere `.^where` over `.^all.grep`)
ZzZombo Nope, doesn't work.
Xliff SmokeMachine: Trust me on this. They'd appreciate the option
SmokeMachine Xliff: the idea is to use raku's syntax...
Xliff Again, you can keep .^all.grep
But you are already extending the metamodel, so why not make it more accessible to people expecting "where"? 01:52
And this does not break the raku syntax any more than Red already does
s/break/extend/ 01:53
SmokeMachine Xliff: I'm extending the meta model mostly to return a ResultSeq to make it possible to the user use raku's syntax...
Xliff SmokeMachine: The purity is nice and all, but the people who would be interested in Red (and hence drawn to Raku) couldn't give a rats butt about the purity of the syntax 01:54
The advantage of the alias is to give them a starting point and allow them to grow into it.
If it is as simple as I think it might be, then let me see if I can whip up a PR...
SmokeMachine Xliff: what do you think about getting more people's opinions? because, sorry, but a still think people would not use `.^where`... 01:57
Xliff Nope. Was not that hard at all. 01:58
method where($obj, Callable $filter --> Red::ResultSeq) { $obj.^all.grep($filter) } # Alias for .^all.grep(...)
SmokeMachine: Even though this is NOT SQL, there is a reason why SQL is the defacto way to query data. 01:59
And SELECT almost always goes with a particular keyword.
And all I'm suggesting is an alias.
SmokeMachine m: say do given 42 { where :is-prime { "Yes" }; default { "No" } }
camelia 5===SORRY!5=== Error while compiling <tmp>
Unexpected block in infix position (missing statement control word before the expression?)
at <tmp>:1
------> 3say do given 42 { where :is-prime7⏏5 { "Yes" }; default { "No" } }
SmokeMachine m: say do given 42 { when :is-prime { "Yes" }; default { "No" } } # ZzZombo 02:00
camelia No
Xliff Ah... that's "when"
SmokeMachine: Please give it some thought. I will submit the PR and maybe we can discuss further? 02:01
SmokeMachine Xliff: I will... but what do you think about a survey?
Xliff I don't mind! :)
SmokeMachine: Also consider this.... how often are you typing ".^all" -- If Red code is littered with it, you really should think of making it implicit to make coding easier, rather than a chore. 02:08
SmokeMachine you can just save it into a variable...
Xliff That's NOT what I'm talking about. 02:09
Yes, you can save it into a variable, but why make that necessary?
If I want to pull anything out of a model, it's going to have to have a .^all after it in one way shape or form. 02:10
Best to give folks a wider variety of coding styles rather than limiting them to one specific design.
... if you can help it...
02:10 jaldhar_ left 02:11 jaldhar_ joined 02:17 jaldhar_ left
SmokeMachine auto-deflating the json and selecting the right value... www.irccloud.com/pastebin/SogvYwTD/ 02:27
Xliff Nice! 02:33
SmokeMachine Xliff: github.com/FCO/Red/blob/join/t/36-json.t 02:38
Xliff :) 02:56
ZzZombo m: say 41, 42 02:57
m: 41 [&say] 42
camelia 4142
WARNINGS for <tmp>:
Useless use of &say in sink context (line 1)
ZzZombo ??
Xliff github.com/FCO/Red/pull/405 03:16
ZzZombo m: False but True.so.say 03:28
camelia True
ZzZombo :P
m: False but True.say
camelia True
ZzZombo oh, what have I done.
m: my $a is Array 03:56
camelia 5===SORRY!5=== Error while compiling <tmp>
is trait on $-sigil variable not yet implemented. Sorry.
Did you mean: my Array $a?
at <tmp>:1
------> 3my $a is Array7⏏5<EOL>
expecting any of:
ZzZombo m: my %a is Array
camelia ( no output )
ZzZombo m: my %a is Array;dd $a
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$a' is not declared. Did you mean '%a'?
at <tmp>:1
------> 3my %a is Array;dd 7⏏5$a
ZzZombo m: my %a is Array;dd %a
camelia Array element = []
ZzZombo m: my %a is Array = 1,2,3;dd %a
camelia Array element = [1, 2, 3]
ZzZombo m: my %a is Array = 1,2,3;dd %a[0]
camelia Int element = 1
ZzZombo m: my %a is True;dd %a
camelia 5===SORRY!5=== Error while compiling <tmp>
Can't use unknown trait 'is' -> 'unknown subtype' in a variable declaration.
at <tmp>:1
------> 3my %a is True7⏏5;dd %a
expecting any of:
ZzZombo m: my %a is Int;dd %a 03:57
camelia 0
ZzZombo Huh?
04:57 squashable6 left 04:58 xinming_ left
ZzZombo my $?ASD = 'asd' 04:58
m: my $?ASD = 'asd' 04:59
camelia 5===SORRY!5=== Error while compiling <tmp>
Cannot use ? twigil on 'my' variable because it is reserved
at <tmp>:1
------> 3my $?ASD7⏏5 = 'asd'
ZzZombo m: $?FILE.say
camelia <tmp>
04:59 xinming_ joined
ZzZombo m: $?FILE.io.f 04:59
camelia No such method 'io' for invocant of type 'Str'. Did you mean 'so'?
in block <unit> at <tmp> line 1
ZzZombo m: $?FILE.IO.f
camelia ( no output )
ZzZombo m: $?FILE.IO.f.say
camelia True
ZzZombo m: $?FILE.IO.e.say
camelia True
05:00 squashable6 joined 06:00 tellable6 left, evalable6 left, squashable6 left, statisfiable6 joined, nativecallable6 joined, greppable6 joined, releasable6 joined 06:01 unicodable6 joined, committable6 joined, evalable6 joined, quotable6 joined, shareable6 joined 06:02 squashable6 joined, coverable6 joined, benchable6 joined, notable6 joined 06:03 bloatable6 joined, reportable6 joined, tellable6 joined 06:45 Zachac left 06:48 Xliff left 07:31 jmerelo joined 08:04 sena_kun joined 08:08 sena_kun left
ZzZombo m: class A {};-> A() \x{ x.say }(1) 08:17
camelia No such method 'A' for invocant of type 'Int'
in block <unit> at <tmp> line 1
ZzZombo Shouldn't this fail in compile time rather than run-time?
08:23 sena_kun joined 08:26 sena_kun left 08:39 jmerelo left 08:51 sena_kun joined 09:02 donaldh left 09:08 epony joined
ZzZombo Is there a way to implement Java-like annotations? 09:14
tobs ZzZombo: you can add custom traits docs.perl6.org/type/Sub#index-entr...eclarator) 09:25
ZzZombo But I need to somehow reference declared traits then
tobs if you mean Java-syntax-like, that will require more work.
I'm not following what you want to do. "reference" where and in which way? 09:29
ZzZombo What? Just declaring traits by itself does nothing. You need to reference a declared trait later to make them work as annotations. 09:54
09:58 chloekek joined
sena_kun ZzZombo, you can reference custom traits at "usual" places. 10:19
though, I think, only `is` will be parsed correctly without changes to grammar 10:22
tobs m: multi trait_mod:<is> (Method $meth, :$override!) { say "you should override $meth.name()" }; class :: { method f is override { say "hi" } }.new.f 10:33
camelia you should override f
tobs ZzZombo: sorry, how to apply a trait was obvious for me, so I didn't think you were asking about that. You stick it to the thing it should apply to, in this case with an "is". 10:35
ZzZombo Do you know what annotations are? They are referenced are run-time. Traits are applied at compile time. I do not understand what are you trying to show me. 10:44
sena_kun you can apply roles to things using annotations and check them at runtime, no? 10:48
10:52 Altai-man_ joined 10:54 sena_kun left 11:07 chloekek left
tobs yes exactly, you can change runtime behaviour or look of things at compile time, by mixing in or wrapping. 11:09
m: role Overridden {}; multi trait_mod:<is> (Method $meth, :$override!) { $meth does Overridden }; class A { method f is override { say "hi" } }; say A.^lookup('f') ~~ Overridden 11:10
camelia True
ZzZombo m: role Overridden {}; multi trait_mod:<is> (Attribute $a, :$override!) { $a does Overridden }; class A { has $.f is override = 123 }; 11:13
camelia ( no output )
ZzZombo m: role Overridden {}; multi trait_mod:<is> ($a, :$override!) { $a does Overridden }; class A { has $.f is override = 123 };
camelia 5===SORRY!5=== Error while compiling <tmp>
Can't use unknown trait 'is' -> 'override' in an attribute declaration.
at <tmp>:1
expecting any of:
ZzZombo m: role Overridden {}; multi trait_mod:<is> (Any $a, :$override!) { $a does Overridden }; class A { has $.f is override = 123 };
camelia 5===SORRY!5=== Error while compiling <tmp>
Can't use unknown trait 'is' -> 'override' in an attribute declaration.
at <tmp>:1
expecting any of:
11:36 chloekek joined
SmokeMachine Xliff: if we are going to create aliases for `.^all.grep` and `.^all.map`, why not call they `.^grep` and `.^map`? 11:47
tellable6 SmokeMachine, I'll pass your message to Xliff
SmokeMachine Xliff: and, update is just one of the uses of `.^all.map`... 11:51
tellable6 SmokeMachine, I'll pass your message to Xliff
12:11 laif joined 12:12 laif left 12:17 squashable6 left 12:20 squashable6 joined 12:28 chloekek left 12:52 sena_kun joined 12:54 Altai-man_ left 12:56 jaldhar_ joined 13:10 jaldhar_ left, jaldhar_ joined 13:22 jaldhar_ left, jaldhar_ joined 13:26 jaldhar_ left, jaldhar_ joined 13:38 jaldhar_ left, jaldhar_ joined 13:42 jaldhar_ left, jaldhar_ joined 13:46 jaldhar_ left, jaldhar_ joined 13:54 jaldhar_ left, jaldhar_ joined 13:56 jaldhar_ is now known as jaldhar 13:57 leah2 joined 13:58 jaldhar left, jaldhar joined 14:00 jaldhar left, jaldhar joined 14:22 lucasb joined
ZzZombo m: say qq;asd; 14:28
camelia asd
ZzZombo m: say qq>asd> 14:29
camelia 5===SORRY!5=== Error while compiling <tmp>
Use of a closing delimiter for an opener is reserved
at <tmp>:1
------> 3say qq7⏏5>asd>
14:36 mid_home joined 14:38 jaldhar left, jaldhar joined 14:42 jaldhar left, jaldhar joined 14:45 AlexDaniel joined, AlexDaniel left, AlexDaniel joined
AlexDaniel m: sub foo() { return <a b c>, 42 }; my (@a, $b) = foo; say @a 14:46
camelia [(a b c) 42]
AlexDaniel how do I make it return just <a b c> ?
I know I can make it $a instead but I want to keep it as @a
14:46 jaldhar left
AlexDaniel m: sub foo() { return <a b c>, 42 }; my ($a, $b) = foo; say $a 14:46
camelia (a b c)
AlexDaniel so, that, but with @a
14:46 jaldhar joined
AlexDaniel m: sub foo() { return <a b c>, 42 }; my (@a, $b) := foo; say @a 14:47
camelia (a b c)
AlexDaniel any other options?
m: sub foo() { return <a b c>, 42 }; my @a; my $b; (@a, $b) := foo; say @a 14:48
camelia 5===SORRY!5=== Error while compiling <tmp>
Cannot use bind operator with this left-hand side
at <tmp>:1
------> 3 c>, 42 }; my @a; my $b; (@a, $b) := foo7⏏5; say @a
AlexDaniel because that doesn't work
14:52 Altai-man_ joined 14:54 jaldhar left, sena_kun left, jaldhar joined 14:58 veesh left 15:02 jaldhar left, jaldhar joined 15:11 veesh joined 15:13 chloekek joined 15:14 jaldhar left, jaldhar joined 15:16 jaldhar left, jaldhar joined
lucasb IMO, 'my ($x, $y); ($x, $y) := (10, 20)' was supposed to work. If it doesn't, then it's NYI till today 15:17
15:18 jaldhar left, jaldhar joined 15:22 jaldhar left, jaldhar joined 15:26 jaldhar left, jaldhar joined 15:30 jaldhar left, jaldhar joined 15:35 chloekek left
tbrowder i'm trying to read some old p5 files with raku and getting error "Malformed UTF-8" from raku on some files. anyone know a technique for finding the offending characters! 15:37
i've been able to fix some files by visual inspection with vim, but many the new crop of files i'm having trouble with don't yield any clues with vim. 15:39
i've thought about using "od -c" but haven't yet figured out any way to get an output line-by-line except to filter od output through another tool. 15:41
so is there a single tool that will do the job?
lucasb if you type ':set enc?' in vim does it say it's utf8 or latin-1? 15:43
for any offending text file :)
ZzZombo m: dd my (@a, $) = -> { <a b c>, 123 } 15:44
camelia ([-> { #`(Block|81976160) ... }], Any)
ZzZombo m: dd my (@a, $) = -> { <a b c>, 123 }() 15:45
camelia ([("a", "b", "c"), 123], Any)
ZzZombo m: my (@a, $) = -> { <a b c>, 123 }();dd @a
camelia Array @a = [("a", "b", "c"), 123]
ZzZombo m: my (@a) = -> { <a b c>, 123 }();dd @a 15:46
camelia Array @a = [("a", "b", "c"), 123]
15:55 seb__ joined 15:56 seb__ left 15:58 stoned75 joined 16:06 jaldhar left, jaldhar joined 16:08 kktt joined 16:35 thundergnat joined
thundergnat ZzZombo: Regarding trait handles; perhaps rosettacode.org/wiki/History_variables#Perl_6 may clarify how / why you may use it. 16:36
16:41 chloekek joined 16:44 stoned75 left 16:52 sena_kun joined 16:54 Altai-man_ left
robertle hm, on that rosettacode example the handles trait is one interesting thing, but the fact that it's hard to get to work with a "normal" sigil variable, and kinda needs the naked one is, I don't know, unexpected? weird? WAT? 17:23
17:28 rjt_pl joined
thundergnat Yeah, it's a trade-off. Normal scalars ($ sigiled) don't have or need a STORE method. In an effort to save memory and cycles, Rakudo just disallows STORE and it "just works" 99.99% of the time. 17:29
Cheat until you get caught basically.
That was over-simplified, $ sigiled variables don't use a STORE method, rather they use special low-level syntax to do assignment. 17:32
17:33 mid_home left 17:38 jaldhar left, jaldhar joined 17:40 jaldhar left, jaldhar joined 17:42 jaldhar left, jaldhar joined 17:44 jaldhar left
thundergnat Arguably that is a bug though. 17:44
17:44 jaldhar joined 17:46 jaldhar left, jaldhar joined 17:48 jaldhar left, jaldhar joined 17:53 finanalyst joined
discord6 <theangryepicbanana> I'm having an odd issue with my code where it's taking a long time to compile and I'm not sure why. here's the link: repl.it/@theangryepicbanana/Raku-editor (online ide. yes I know it's using 2019.3 but that shouldn't matter) 17:53
17:54 jaldhar left, jaldhar joined
discord6 <theangryepicbanana> feel free to @ me (I'm on the discord bridge) if you know something 17:55
17:55 jmerelo joined 17:56 jaldhar left, jaldhar joined 18:02 jaldhar left, jaldhar joined 18:04 jaldhar left
thundergnat theangryepicbanana: FWIW, it compiles/runs locally for me in slightly less than .4 seconds (2019.07.1 Linux Mint 19.2) 18:04
18:04 jaldhar joined 18:06 jaldhar left, jaldhar joined
discord6 <theangryepicbanana> hmm 18:06
<theangryepicbanana> I've never had an issue like this for larger projects before 18:07
18:08 jaldhar left, jaldhar joined 18:14 jaldhar left, jaldhar joined 18:16 jaldhar left, jaldhar joined 18:18 jaldhar left, jaldhar joined 18:20 jaldhar left, jaldhar joined 18:22 jaldhar left, jaldhar joined 18:30 jaldhar left, jaldhar joined 18:32 jaldhar left, jaldhar joined 18:44 jaldhar left, jaldhar joined 18:46 jaldhar left, jaldhar joined 18:50 jaldhar left, jaldhar joined 18:52 Altai-man_ joined 18:54 jaldhar left, sena_kun left, jaldhar joined 18:58 wildtrees joined 19:00 jaldhar left, jmerelo left, jaldhar joined 19:01 lucasb left 19:04 jaldhar left, jaldhar joined 19:09 cpan-raku left 19:10 jaldhar left, jaldhar joined 19:13 finanalyst left, cpan-raku joined, cpan-raku left, cpan-raku joined 19:16 squashable6 left 19:18 squashable6 joined 19:20 jaldhar left, jaldhar joined 19:38 user3 joined, user3 left 19:47 thundergnat left 20:47 releasable6 left, notable6 left, nativecallable6 left, statisfiable6 left, greppable6 left, squashable6 left, shareable6 left, committable6 left, quotable6 left, bloatable6 left, unicodable6 left, coverable6 left, reportable6 left, benchable6 left 20:48 releasable6 joined, squashable6 joined, reportable6 joined, statisfiable6 joined 20:49 unicodable6 joined, committable6 joined, nativecallable6 joined, benchable6 joined, coverable6 joined 20:50 bloatable6 joined, greppable6 joined, notable6 joined, shareable6 joined, quotable6 joined 20:53 sena_kun joined 20:55 Altai-man_ left 21:00 kktt left, kktt joined 21:16 eseyman joined 21:20 finanalyst joined 21:24 sena_kun left 21:27 chloekek left 21:56 tejr left 22:02 pubwrk joined
pubwrk Could anybody say if it's feasible to write Raku modules that wrap core functionality written in C (or at least something exposing a C API) similar to Numpy? 22:07
El_Che pubwrk: docs.perl6.org/language/nativecall 22:10
brass NativeCall is an absolute blessing 22:18
22:26 Altreus left, Altreus joined
pubwrk El_Che: I was reading through that this morning, and I found an article about using it with C++. The article made it sound like memory management can actually get kind of hairy 22:31
I guess a better question is if anyone is doing that sort of thing now. That is, are there folks using Raku as a high level api for fortran/C/whatever? 22:33
japhb pubwrk: Yes, it's used quite a bit. Bindings to encryption, compression/archiving, and UI toolkits are common uses. 22:47
22:52 patrickb joined
pubwrk japhb: Thank you, that's good to know. I've looked at raku a little bit, and I already have a lot of experience with Python (very little with Perl), so that was one of the questions I had about how useful it would be to start using Raku for more scripting problems that I'm using Python for now 23:16
since I lean on numpy, pandas and libraries like it pretty often
23:24 finanalyst left 23:47 jaldhar left 23:57 mid_laptop joined