🦋 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.
xinming github.com/jonathanstowe/Attribute-Lazy <--- Is this "feature" moved core? 09:41
antononcube Does anyone have / know Raku Docker images (or specs from them) that have “DB:Pg” and “DB::SQLite” installed ? 12:15
lizmat xinming: not sure what your question is ? 12:22
xinming lizmat: I saw in stackoverflow, someone said, Attribute::Lazy thing may be moved to core, So I'm not sure. 12:53
lizmat m: class A { has $.a is lazy } 12:54
camelia ===SORRY!=== Error while compiling <tmp>
Can't use unknown trait 'is' -> 'lazy' in an attribute declaration.
at <tmp>:1
expecting any of:
rw
readonly
box_target
leading_docs
trailing_do…
lizmat guess not :-*(
xinming lizmat: BTW, I think I found a bug, not sure it's bug in DBIish or core
!paste
?paste
lizmat we usually use something like gist.github.com 12:55
ab5tract any pastebin will do, of course 12:56
xinming pastebin.com/KnicMGC0 <--- With this script, We'll get eror 12:58
Cannot look up attributes in a VMNull type object. Did you forget a '.new'?
in block <unit> at raku-will-l
in block <unit> at raku-will-lazy-bug.raku line 10
lizmat m: class A { has $.a will lazy } 12:59
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> class A { has $.a will lazy ⏏}
expecting any of:
block or pointy block
lizmat m: class A { has $.a will lazy { "foo" } }
camelia ===SORRY!=== Error while compiling <tmp>
Can't use unknown trait 'will' -> 'lazy' in an attribute declaration.
at <tmp>:1
expecting any of:
lazy
xinming We need Attribute::Lazy
lizmat m: class A { has $.a will lazy({ "foo" }) }
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> class A { has $.a will lazy⏏({ "foo" }) }
expecting any of:
block or pointy block
xinming I think Attribute::Lazy is still not in core yet.
lizmat it most definitely is not 13:00
xinming But I don't think it's probably a Attribute::Lazy bug, Probably DBIish uses c bindings caused some bugs
Some c bindings affected the core.
lizmat xinming: could you post a --ll-exception backtrace? 13:02
ab5tract xiinming: does it work as expected with a less complex thingy inside the lazy block? `has $.re will lazy { /foo/ }` or such?
lizmat golf: use Attribute::Lazy; class A { has $.a; has $.b will lazy { $!a } }; A.new.b 13:03
xinming pastebin.com/F4UdBcVk
lizmat Cannot look up attributes in a VMNull type object. Did you forget a '.new'?
xinming lizmat: yea, this is the shortest code to trigger the bug 13:04
xinming So it's a bug in Attribute::Lazy? 13:04
lizmat m: class A { }; use nqp; nqp::getattr(nqp::null, A, '$!') 13:07
camelia Cannot look up attributes in a VMNull type object. Did you forget a '.new'?
in block <unit> at <tmp> line 1
lizmat that's basically the error
looking at the generated QAST, it generates a nqp::getattr(self, A, '$!') 13:08
*but* no self is known in the "lazy" block
use Attribute::Lazy; class A { has $.a; has $.b will lazy { self } }; dd A.new.b # Mu 13:09
so there *is* a "self" known in that scope, it's just that it isn't getting set 13:10
xinming: but I did find a workaround 13:12
use Attribute::Lazy; class A { has $.a = 42; has $.b will lazy -> $self { $self.a } }; dd A.new.b 13:13
^^
xinming: the $self is just for clarity, it could be named anything 13:14
actually, a better workaround;
use Attribute::Lazy; class A { has $.a = 42; has $.b will lazy { .a } }; dd A.new.b # 42
the object *is* available as the topic inside the block, so instead of: $!dbh.prepare("SELECT 1"); 13:15
you should do: .dbi.prepare("SELECT 1"); 13:16
that's even one char less
ab5tract that's really interesting actually. It might be a cool exercise to rewrite Attribute::Lazy in RakuAST 13:21
lizmat or just add it to core and allow: has $.b will lazy *.a
as syntax
xinming thanks 13:25
Yea, I think `-> $self` is more clear version
tbrowder m: my $x = "\n"; say ($x ~~ /\n/).so 15:26
camelia True
tbrowder my $x = '\n'; say ($x ~~ /\n/).so 15:27
evalable6 False
tbrowder m: my $x = '\t'; say ($x ~~ /\t/).so 15:29
camelia False
tbrowder m: my $x = "\t"; say ($x ~~ /\t/).so 15:30
camelia True
tbrowder reality check. " vs ' with special chars and ~~ 15:31
hm, which quoting construct enables the equiv of ["\n", "\t"] without entering the double quotes? 15:49
m: my @a = qq[ \n \t]; say @a.gist 15:50
camelia [
]
tbrowder m: my @a = qq[\n]; say (@a[0] ~~ /\n/).so 15:52
camelia True
tbrowder looks like that's what i'm looking for 15:53
tbrowder nope, not quite it... 16:05