🦋 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.
Xliff m: class X::E is Exception { method new ($m) { self.bless( message => $m ); }; }; sub a { CATCH { when X::E { .message.say }; }; X::E.new("Bloop!").throw }; a 11:19
camelia Stub code executed
in block at <tmp> line 1
in any at <tmp> line 1
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
tellable6 2023-05-16T19:52:48Z #raku-dev <nine> Xliff: what do you mean by the Need RakuAST node "not working"?
Xliff Is that right?
gfldex lolibloggedalittle: gfldex.wordpress.com/2023/05/17/pl...g-strings/ 12:50
pusha hi! I'd like to ask some Qs about Raku 14:21
dutchie pusha: in irc, you should just ask your question. no need to request permission first 14:25
pusha ok mb
asked it in #raku-beginner 14:26
Xliff gfldex: "Again, I need a way to turn words into Sets. I shall do so be invoking the coercion-protocol with new-method." shouldn't "be" be "by" ? 14:53
lizmat Xliff++ oops, missed that :-) 14:54
gfldex Xliff: thanks! 14:55
Luckily the intarwebs are full of nitpickers or I would never know that anybody reads the nonsense I write. :-> 14:57
Xliff gfldex: Nice article, tho. 14:58
TIL that type constraints are valid in Array refs.
gfldex Coersion types turn out to be really useful when you think functional but program object oriented. 14:59
tbrowder__ lizmat: disregard my comment ref ending- 15:01
lizmat ?
tbrowder__ type pod paras. 15:02
i'm confusing extracting $=pod and doing things with it for doc layout. 15:03
lizmat ah, ok
FWIW, I think the future of rakudoc rendering is by walking the RakuAST tree 15:04
tbrowder__ if you have solved the table cell problem for embedded tables and formating codes you are light-years ahead of the current capability
lizmat did you gist me an example of embedded tables already ? 15:05
tbrowder__ no, i never got to that poont
*point,
lizmat ok, then I cannot tell you whether solved it 15:06
wrt to formatting codes in cells, that should be emininently doable
tbrowder__ at the time i never thought of it, but someone, maybe leont, wanted it. and we would all like formatting codes in table 15:07
Xliff gfldex: It is. I use it extensively in my NativeCall stuff.
lizmat tbrowder__: ok, then I will make that so, depending on :allow setting 15:08
I've got that part of the code in my head now, better make efficient use of that now
tbrowder__ roger! 15:14
patrickb What ways are there to generate classes at runtime? 15:16
Except EVAL that is.
lizmat with RakuAST?
tbrowder__ hm, i need to see tonyo's Data::Dumpl used on $=pod
patrickb I guess RakuAST could do this. But is there some other way with some mop trickery? 15:17
tbrowder__ *Data::Dump
lizmat patrickb: look for new_type in src/Perl6/Metamodel ? 15:18
tbrowder__ i just found "constant $foo = MyClass.new;" works 15:19
patrickb lizmat: Thanks! I'm brainstorming how a runtime generated Gtk binding could work. I guess there are options. 15:23
leont patrickb: I've been considering writing such a thing for years but never had the tuits. I assume you know about gobject introspection? 15:24
patrickb leont: I do. 15:25
leont Excellent!
patrickb Gnome::Gtk3 might take that direction.
lizmat patrickb: fwiw, I think going the RakuAST way would be preferable over the mop way at this point 15:26
gfldex Africa still doesn't like Raku much: gist.githubusercontent.com/gfldex/...-there.png
leont gfldex: or is largely not privileged enough to spend effort on a language that won't earn one money on the short term 15:29
tbrowder__ m: enum Foo <a b>; sub f(Foo :$type) { say $type.gist} ; f(:type(Foo<a>)); 15:30
camelia Type check failed in binding to parameter '$type'; expected Foo but got Any (Any)
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
Nemokosch "short term" might even be euphemistic here
lizmat Nemokosch snarky! 15:31
gfldex patrickb: Please note that the MOP is not well documented. You may have to read Rakudo /src/Perl6 15:35
/Metamodel/ to get everything you need.
leont It's very abstracted IME, which is probably good from a DRY POV but can make it hard to figure out what's going on 15:37
Nemokosch no need to apply value judgements like that onto facts 15:38
Xliff patrickb: GIR is probably the way to go. 15:48
I went the long way.
Plus....run-time generation will be ... slower.
patrickb: github.com/Xliff/p6-GtkPlus 15:49
lizmat: Wouldn't RakuAST still have the benefit of being precompiled?
lizmat it could, but we currently have no way to do that at runtime 15:51
patrickb Xliff: But your bindings are hand written, right? Does your recommendation of GIR mean that you have given up on your bindings? 15:53
Xliff Nope. 16:01
Hand written bindings have the advantage of tighter integration with Raku.
GIR won't get you that without some work.
lizmat: Couldn't you EVAL the tree at BEGIN ? 16:02
lizmat eys
yes
Xliff That would still be a part of the precompile payload then. Right? 16:03
lizmat no, not by itself
Xliff Oh.
lizmat BEGIN code is run and then discarded
Xliff Um.
m: my $data; BEGIN { $data = 1 }; $data.say 16:04
camelia 1
patrickb Xliff: There is some discussion at github.com/MARTIMM/gnome-source-sk...l/issues/1
Xliff lizmat: So the tree can be precompiled, but not the bytecode... 16:05
Hmmm...
lizmat if you do something like:
my $mainline = BEGIN $ast.EVAL; $mainline()
that might work
Xliff lizmat: That's what I am hoping for. Thanks! 16:08
rf Afternoon folks 18:31
lizmat rf o/ 18:32
rf I am assuming it is morning or evening for you liz?
lizmat evening 8:32pm
rf Well, good evening in that case :-) 18:33
lizmat :-)
tonyo tbrowder__: ? 20:05
tonyo patrickb: a lot of stuff can be done just using .^compose 20:41
m: ub gen-class(%fields) { my $class = class :: { }; for %fields -> $pair { $class.HOW.add_attribute($class, Attribute.new(:name("\$!{$pair.key}"), :type($pair.value), :package<Anon>)); $class.HOW.add_method($pair.key, $pair.key, method { 5 }); }; $class.^compose; $class; }; my $cls = gen-class({ :a(Int), :b(Str) }); dd $cls.a; # patrickb this can be extrapolated upon 20:56
camelia ===SORRY!=== Error while compiling <tmp>
Variable '%fields' is not declared. Perhaps you forgot a 'sub' if this
was intended to be part of a signature?
at <tmp>:1
------> ub gen-class(⏏%fields) { my $class = class :: { }; for
tonyo m: sub gen-class(%fields) { my $class = class :: { }; for %fields -> $pair { $class.HOW.add_attribute($class, Attribute.new(:name("\$!{$pair.key}"), :type($pair.value), :package<Anon>)); $class.HOW.add_method($pair.key, $pair.key, method { 5 }); }; $class.^compose; $class; }; my $cls = gen-class({ :a(Int), :b(Str) }); dd $cls.a; # patrickb this can be extrapolated upon 20:57
camelia 5
tonyo this is how xoos hydrated data from a db, fwiw
tbrowder__ tonyo: the failed attempt was a try at passing an enum member to a sub. i could pass just the key, but i think there is a more rakuish way to do it 21:54