🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
avuserow blogs a bit: dev.to/avuserow/avoiding-the-end-w...ueries-1i1 00:30
uzl[m] avuserow: ++ 01:48
leont avuserow: TBH, all the advantages you list in your first article apply to SQL::Abstract as well. 02:27
avuserow leont: I think SQL::Builder provides an easier way to understand what SQL is generated vs SQL::Abstract. For instance, the majority of SELECT queries in my application have one join, if not more 02:58
I didn't see if Abstract supports multiple joins and subqueries, and I think the DSL gets in the way here 02:59
I do think that Abstract's DSL is way nicer for smaller queries 03:00
elcaro I mentioned before, but FYI it appears raku.land has not refreshed in 3 days 03:01
avuserow though there is an interesting gotcha with SQL::Abstract and many other query builders: blog.kazuhooku.com/2014/07/the-json...ility.html - this reflects on some Perl 5 modules but the same thing applies. 03:03
tldr: if you accept JSON input from users, and use that in your query syntax, users can influence your queries more than you'd expect. SQL::Builder avoids this in its where clause syntax 03:05
elcaro: I also mentioned this in #raku-land, hopefully they can take a look 03:07
elcaro Thanks avuserow 03:16
Xliff Huh! I just used ChatGPT to write some OpenGL code for me.... and it finally worked! (I've been at this all day) 03:59
gfldex It was only a matter of time for humans to automate cargo culting. 07:19
Nemokosch ultimately, sigilless variables bind on first assignment 07:36
that's all their peculiarity 07:37
leont avuserow: it does support both multiple joins and subqueries, but you're right I don't have that well documented. 12:04
And yeah, the insertion issue is real. I'm working on a solution though. 12:05
The only overload in conditional that's reachable and potentially problematic is the Map one, so I just have to replace that 12:10
leont And arguably the Any:U case, but I can replace that with Nil when I eliminate the Hash case 12:43
SmokeMachine coleman: did you have time to take a look at github.com/FCO/nats ? Please let me know your opinions 13:36
coleman I did not yet. I can recommend you join their Slack, if you haven't already. They are quite friendly. 14:09
General advice? Focus on the "core" client protocol first: connections, pub/sub, topics/subjects. 14:13
Then auth subsystem. They are quite sophisticated with auth. But NATS is also usable without auth. 14:15
SmokeMachine coleman: thanks! Great advices! Currently my client is handling only ping, pong, pub, sub and msg. And also accepts partially info and sends connect… 14:17
coleman: I haven’t even touched auth yet…
coleman At the very end, layer on the Jetstream stuff. It should be a clean abstraction over core NATS. The core protocol has been around a while and is stable.
Good!!! 14:18
it can wait.
SmokeMachine But I think my next step will be write some tests… there are not tests yet… 14:19
Xliff \o 14:47
uzl[m] I'm reading this codesections's RA article (raku-advent.blog/2022/12/20/sigils/), and I'm like "the docs should have this table summarizing sigils so let me create an issue" until I go to the sigils page, and the table is already there lmao. 10/10 for foresight lol 15:01
librasteve o/ 15:32
anyone know how I take a list of Str and parse in the same way as angle bracket literal like this <42 42e0 42/1 42.0> 15:34
ie. to result in a list of Allomorphs?
(trying to avoid MONKEY-SEE-NO-EVAL) 15:38
SmokeMachine m: say “42 42e0 42/ 42.0”.words.map: val * 15:43
camelia Value of type Whatever uselessly passed to val()
in block <unit> at <tmp> line 1
Cannot map a Seq using '*'
Did a * (Whatever) get absorbed by a list?
in block <unit> at <tmp> line 1
SmokeMachine m: say “42 42e0 42/ 42.0”.words.map: .&val
camelia Value of type Any uselessly passed to val()
in block <unit> at <tmp> line 1
Cannot map a Seq using 'Any'
Did a * (Whatever) get absorbed by a list?
in block <unit> at <tmp> line 1
librasteve ah - val is exactly what I need - brilliant! 15:46
SmokeMachine m: say “42 42e0 42/1 42.0”.words.map: *.&val 15:50
camelia (42 42e0 42/1 42.0)
SmokeMachine m: say “42 42e0 42/1 42.0”.words.map: *.&val.^name 15:58
camelia (IntStr NumStr RatStr RatStr)
SmokeMachine Does anyone have a suggestion on how Nats::Server should be called? It’s not a service… but I don’t think it should be called client… any suggestions? github.com/FCO/nats/issues/1 16:28
uzl[m] m: my $a := 3; say $a; $a := 'hi'; say $a; 17:36
camelia 3
hi
uzl[m] m: my \b := 3; say b; b := 'hi'; say b; 17:37
camelia ===SORRY!=== Error while compiling <tmp>
Cannot bind to 'b' because it is a term and terms cannot be rebound
at <tmp>:1
------> my \b := 3; say b; b := 'hi'⏏; say b;
uzl[m] Why can I re-bind to a sigilled variable?
lizmat uzl[m]: because a sigilless item is a "term", and you cannot change terms (as the error message says) 17:39
if you want to be able to re-bind, bind to a variable
m: my $a := 42; $a := 666; say $a
camelia 666
uzl[m] Got it! How is a "term" defined in Raku? There's docs.raku.org/language/terms but it doesn't provide a definition 17:44
SmokeMachine m: sub term:<bla>() { 42 }; say bla 17:45
camelia 42
Nemokosch what is this for? 17:46
uzl[m] "You can use term:<> to introduce new terms, which is handy for introducing constants that defy the rules of normal identifiers:" 17:48
Thanks, I just read this lol
Nemokosch m: my \term:<-foo> = 12; say -foo; 18:13
Raku eval 12
Nemokosch lol, magic
lizmat appears unstoppable: dev.to/lizmat/walking-the-rakuast-tree-3fbd 18:23
avuserow lizmat++ # unstoppable blogging :) 18:26
Xliff Can a proto affect the multi that is used? 21:52
m: proto sub a (|c) { if (c.head % 2).not { nextwith(|c) } else { say "Bleah!" }; }; multi sub a ($b) { say "Non-bleah!" }; a(2); a("P")
camelia nextwith is not in the dynamic scope of a dispatcher
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff I'd like the proto to run first and then determine which multi is run after. 21:53
lizmat a proto can be a sub / method like anything else 21:55
you do {*} to do the dispatch
Xliff Yes, but you cannot affect the dispatched called, correct? 21:56
So I'd have to do something akin to.... 21:57
lizmat well, you can fetch the available candidates in the proto and then call them depending on something else?
Xliff How would I do that?
lizmat self.^candidates ?
Xliff Oh. use .^cando and then dispatch to the method itself?
lizmat e.g. yes
Xliff OK. I got it. 21:58
Thanks!
lizmat yw :-)
Xliff m: multi sub a (|c) { if (c.head % 2).not { samewith(|c, :int) } else { samewith(|c, :str); }; multi sub a ($b, :$int is required) { say "Non-bleah!" }; multi sub a ($b, :$str is required) { say "Bleah!" }; a(2); a("P") 22:01
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> required) { say "Bleah!" }; a(2); a("P")⏏<EOL>
expecting any of:
statement end
statement modifier
statement modifier loo…
Xliff m: multi sub a (|c) { if (c.head % 2).not { samewith(|c, :int) } else { samewith(|c, :str); }; }; multi sub a ($b, :$int is required) { say "Non-bleah!" }; multi sub a ($b, :$str is required) { say "Bleah!" }; a(2); a("P")
camelia Non-bleah!
Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏P' (indicated by ⏏)
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff m: multi sub a (|c) { if (c.head ~~ Int && c.head % 2).not { samewith(|c, :int) } else { samewith(|c, :str); }; }; multi sub a ($b, :$int is required) { say "Non-bleah!" }; multi sub a ($b, :$str is required) { say "Bleah!" }; a(2); a("P")
camelia Non-bleah!
Non-bleah!
Xliff m: multi sub a (|c) { if (c.head ~~ Int && c.head % 2).not { samewith(|c, :int) } else { samewith(|c, :str); }; }; multi sub a ($b, :$int is required) { say "Non-bleah!" }; multi sub a ($b, :$str is required) { say "Bleah!" }; a(3); a("P") 22:02
camelia Bleah!
Non-bleah!
Xliff Something like that...
m: multi sub a (|c) { if (c.head ~~ Int && c.head % 2).not { samewith(|c, :odd) } else { samewith(|c, :str); }; }; multi sub a ($b, :$str is required) { say "Non-bleah!" }; multi sub a ($b, :$odd is required) { say "Bleah!" }; a(3); a("P") 22:03
camelia Non-bleah!
Bleah!
Xliff m: multi sub a (|c) { if (c.head ~~ Int && c.head % 2).not { samewith(|c, :str) } else { samewith(|c, :odd); }; }; multi sub a ($b, :$str is required) { say "Non-bleah!" }; multi sub a ($b, :$odd is required) { say "Bleah!" }; a(3); a("P") 22:04
camelia Bleah!
Non-bleah!