🦋 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.
Xliff I would actually write a sub that wraps ReqQueryValueExW which does all that for you so you can use it more or less like you'd expect. 00:01
ToddAndMargo would you give mr. confused here another vpaste?
Xliff LOL
Of the wrapper?
ToddAndMargo of what you sent me previously 00:05
Xliff vpaste.net/pKKuI 00:07
Ah, crap. That's wrong. 00:09
vpaste.net/At8QP <- This one isn't
00:13 sena_kun left
ToddAndMargo I has to go help my wife with something. I will have to change some stuff around 00:16
Thank you!
Xliff OK. Good luck!
yw
Kaeipi i'd appreciate any input you guys might have on www.reddit.com/r/rakulang/comments...ant_to_be/ 00:22
00:27 Kaeipi left, sena_kun joined 00:28 Kaeipi joined 00:30 chloekek left 00:41 ToddAndMargo left
Xliff .tell jnthn Is there a mechanism that allows a raku script to compile raku code and emit .moarvm bytecode? If so, is there another mechanism that will allow a raku script to then execute that bytecode? EVAL, maybe? 01:05
tellable6 Xliff, I'll pass your message to jnthn
01:05 wildtrees left 01:41 vrurg_ is now known as vrurg 02:08 Tirifto left 02:14 sena_kun left 02:30 sena_kun joined 02:35 guifa2 joined 02:54 stoned75 left 03:50 guifa2 left 03:51 guifa2 joined, guifa2 left 04:15 sena_kun left 04:16 johnjohn101 joined 04:20 marinin[t] left 04:24 mahmudov left 04:30 sena_kun joined 04:56 Kaeipi left 04:57 Kaeipi joined, Kaeipi left 04:58 Kaeipi joined 05:14 pony is now known as no-n 05:36 johnjohn101 left 06:14 sena_kun left 06:18 sauvin joined 06:22 RobRaku joined 06:28 cognomin_ joined 06:30 sena_kun joined 06:31 cognominal left 07:31 sourceable6 left, nativecallable6 left, greppable6 left, notable6 left, releasable6 left, quotable6 left, benchable6 left, coverable6 left, tellable6 left, reportable6 left, bisectable6 left, bloatable6 left, statisfiable6 left, squashable6 left, shareable6 left, evalable6 left, committable6 left, unicodable6 left 07:32 statisfiable6 joined, unicodable6 joined, shareable6 joined, benchable6 joined, nativecallable6 joined, quotable6 joined 07:33 sourceable6 joined, notable6 joined, greppable6 joined, committable6 joined, releasable6 joined, coverable6 joined, squashable6 joined, evalable6 joined 07:34 bisectable6 joined, reportable6 joined, tellable6 joined, bloatable6 joined 07:47 holyghost joined 07:50 Xliff left
xinming_ How do we pass an array to multi MAIN? 07:57
For example, multi test ('x', @array) { ... }; I try something like `raku t.p6 x a b c`, It will only display the command line 07:58
08:14 sena_kun left 08:28 sena_kun joined
CIAvash xinming_: You probably want `*@array` 08:33
xinming_ CIAvash: I don't mean that. :-) 08:37
I do mean @array. As when we use :@array, We can do --array 1 --array 2 to pass array. So, I wonder how we do positional arg
CIAvash your example suggested that. so what happens to a value after the array? example: ('x', @array, 'y'). Maybe I'm wrong but I don't think MAIN has a case for that. 08:41
xinming_ CIAvash: If so, I think we should raise error in this case. 08:54
multi test ('xx', @array) { } raise error to mean @array is not supported
in raku multi, test('x', @array, 'y') etst('x', $other-object, 'y') will work as expected 08:55
SmokeMachine: termbin.com/qrey <--- I think you mis-understood me, What I mean multi-column constraint is something like this. 09:07
09:13 rindolf joined 09:15 Voldenet left
xinming_ multi MAIN ('xx', @array) { } should inform user it's error to do so. 09:40
10:08 RobRaku left 10:14 sena_kun left 10:24 RobRaku joined 10:28 sena_kun joined 10:47 mahmudov joined 11:20 Benett joined 11:39 RobRaku left 12:14 sena_kun left 12:27 Tirifto joined 12:29 sena_kun joined 12:40 Voldenet joined, Voldenet left, Voldenet joined
Tirifto Hello! Is my understanding correct that prefixing a variable's name with a colon in subroutine invocation passes a pair to the subroutine, whose key is the variable's name and whose value is the variable's value? (Thus requiring a variable to exist in the current scope with a name identical to the key expected by the subroutine which takes named arguments?) 13:04
sena_kun Tirifto: yes, you are correct. 13:19
Tirifto sena_kun: Thanks! 13:23
xinming_ m: my %h = ("a" .. "z"); %h.perl.say; for %h<>:p.sort(*.key) -> ($k, $v) { [$k, $v].perl.say; } 13:33
camelia {:a("b"), :c("d"), :e("f"), :g("h"), :i("j"), :k("l"), :m("n"), :o("p"), :q("r"), :s("t"), :u("v"), :w("x"), :y("z")}
Too few positionals passed to '<anon>'; expected 2 arguments but got 0 in sub-signature
in block <unit> at <tmp> line 1
xinming_ In this case, How do we unpack the pair produced with .sort method?
as far as I tried, 13:37
m: my %h = ("a" .. "z"); for %h<>:p.sort(*.key) -> (:$key, :$value) { $key.perl.say; }
camelia "a"
"c"
"e"
"g"
"i"
"k"
"m"
"o"
"q"
"s"
"u"
"w"
"y"
xinming_ This worked, But I still wish to know wether it's possible to do something like -> ($key, $value) directly.
Fianlly got it. :-) 13:39
sena_kun m: my %h = ("a" .. "z"); for %h.sort(*.key) -> (:$key, :$value) { $key.perl.say; }
camelia "a"
"c"
"e"
"g"
"i"
"k"
"m"
"o"
"q"
"s"
"u"
"w"
"y"
13:40 evalable6 left, evalable6 joined 14:13 sena_kun left 14:15 mahmudov left
SmokeMachine xinming_: no, it's not working yet... 14:26
14:29 sena_kun joined 14:41 Tirifto left 14:51 cpan-raku left 14:52 cpan-raku joined, cpan-raku left, cpan-raku joined
Kaeipi are there better ways to check if code is being run at compile-time than checking for something like DYNAMIC::<$*W>:exists? 15:14
15:15 veesh left 15:28 veesh joined 15:40 chloekek joined 15:53 mahmudov joined 16:14 sena_kun left
AlexDaniel u: 𓅭 16:24
unicodable6 AlexDaniel, U+1316D EGYPTIAN HIEROGLYPH G039 [Lo] (𓅭)
AlexDaniel u: EGYPTIAN HIEROGLYPH
unicodable6 AlexDaniel, U+13000 EGYPTIAN HIEROGLYPH A001 [Lo] (𓀀)
AlexDaniel, U+13001 EGYPTIAN HIEROGLYPH A002 [Lo] (𓀁)
AlexDaniel, 1080 characters in total: gist.github.com/3b54ca491ec800cb1a...6328b965bc
16:29 sena_kun joined 16:44 Tirifto joined 17:20 mahmudov left 17:26 mahmudov joined 17:31 chloekek left 17:44 Manifest0 joined 17:50 Poohman joined
Poohman Hello all 17:50
m: class A { has Str $.b is rw;} A.^attributes; 17:51
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3class A { has Str $.b is rw;}7⏏5 A.^attributes;
expecting any of:
infix
infix stopper
Poohman m: class A { has Str $.b is rw;}; A.^attributes;
camelia ( no output )
Poohman m: class A { has Str $.b is rw;}; say A.^attributes;
camelia (Str $!b)
Poohman hello all 17:52
why is the ^attributes showing $!b instead of $.b??
17:55 chloekek joined 17:59 wildtrees joined 18:06 rindolf left 18:13 sena_kun left 18:18 rindolf joined
lizmat Poohman: because $!b is the real name of the attribute 18:27
"has $.b" signals that an accessor should be made for the attribute
using $.b in code, is just syntactic sugar for "self.b", with the advantage that it interpolates 18:28
18:28 sena_kun joined
Poohman thanks lizmat - what do you mean by interpolates? 18:30
lizmat say "the value of b is $.b"
vs: 18:31
say "the value of b is {self.b}"
Poohman ok 18:33
sarna hey, I want to be able to take any digits from a number, what would be the optimal way of doing this? in a static language I'd turn that int into a string and then into a char array, and then index into it 18:37
but I think that approach would be suboptimal in raku
lizmat m: dd "foobar".chomp # sarna
camelia "foobar"
lizmat m: dd "foobar".comb # oops
camelia ("f", "o", "o", "b", "a", "r").Seq 18:38
sarna m: dd 1234.comb
camelia ("1", "2", "3", "4").Seq
lizmat m: for "foobar".comb -> $letter { say $letter }
camelia f
o
o
b
a
r
sarna ha, thanks lizmat :D
18:47 RobRaku joined
chloekek You can also use $.b when b is a normal user-defined method. 18:48
p6: class C { method m { "m" }; method n { "l $.m n" } }; C.new.n.say
camelia l m n
lizmat personally, I dislike using that that way, but yeah, you can :-) 18:52
I doubt it will be in the RBP book :-) 18:53
sarna m: dd [1,2][*-2 .. *-1]; dd [1][*-2] or 0; dd ([1][*-2 .. *-1] or [1][*-1]) 18:55
camelia WARNINGS for <tmp>:
Useless use of constant integer 0 in sink context (line 1)
(1, 2)
Failure.new(exception => X::OutOfRange.new(what => "Effective index", got => -1, range => "0..^Inf", comment => Any), backtrace => Backtrace.new)
(Failure.ne…
sarna heck
m: say [1,2][*-2 .. *-1]; say [1][*-2] or 0; say ([1][*-2 .. *-1] or [1][*-1])
camelia WARNINGS for <tmp>:
(1 2)
Useless use of constant integer 0 in sink context (line 1)
Effective index out of range. Is: -1, should be in 0..^Inf
in block <unit> at <tmp> line 1
sarna m: say [1,2][*-2 .. *-1]; say ([1][*-2] or 0); say ([1][*-2 .. *-1] or [1][*-1]) 18:57
camelia (1 2)
Effective index out of range. Is: -1, should be in 0..^Inf
in block <unit> at <tmp> line 1

0
sarna groans
m: say [1,2][*-2 .. *-1]; say ([1][*-2] or 0);
camelia (1 2)
0
sarna m: say ([1][*-2 .. *-1] or [1][*-1])
camelia Effective index out of range. Is: -1, should be in 0..^Inf
in block <unit> at <tmp> line 1
sarna how to make this one work? the third one 18:58
lizmat m: [1][*-2]
camelia Effective index out of range. Is: -1, should be in 0..^Inf
in block <unit> at <tmp> line 1
lizmat m: dd [1,2][*-2]
camelia Int element = 1
lizmat the list is too small to handle * - 2 18:59
sarna yes, and if the list is too small, I want to give it a default value
m: say ([1][*-2] or 0);
camelia 0
sarna like here
but I want to do this with a range (a slice?) instead of just one element
lizmat m: dd [1][*-2 .. *-1] 19:00
camelia (Failure.new(exception => X::OutOfRange.new(what => "Effective index", got => -1, range => "0..^Inf", comment => Any), backtrace => Backtrace.new), 1)
lizmat hmmm
sarna I wonder if that's possible at all :D 19:01
lizmat m: dd [1][*-2 .. *-1] of [1][*-1]
camelia 5===SORRY!5=== Error while compiling <tmp>
Bogus statement
at <tmp>:1
------> 3dd [1][*-2 .. *-1] o7⏏5f [1][*-1]
expecting any of:
whitespace
lizmat m: dd [1][*-2 .. *-1] or [1][*-1]
camelia (Failure.new(exception => X::OutOfRange.new(what => "Effective index", got => -1, range => "0..^Inf", comment => Any), backtrace => Backtrace.new), 1)
lizmat m: dd [1][*-4 .. *-1] or [1][*-1]
camelia (Failure.new(exception => X::OutOfRange.new(what => "Effective index", got => -3, range => "0..^Inf", comment => Any), backtrace => Backtrace.new), Failure.new(exception => X::OutOfRange.new(what => "Effective index", got => -2, range => "0..^Inf", co…
sarna m: my @l = [1]; say ([ @l[*-2] or 0, @l[*-1] or 0]) 19:02
camelia [0 1]
sarna :D
lizmat :-) 19:03
sarna m: my @l = [1]; say [ @l[*-5] or 0 .. @l[*-1] or 0] # unfortunately I get two elements with this one as well
camelia [0 1]
sarna (thought I'd get five or something)
19:03 libertas left 19:11 Xliff joined
Xliff . 19:11
Poohman chloekek: thanks 19:37
will self.new(|%args) work?? 19:42
I want to instantiate a class inside a member function
lizmat Poohman: that should generally work, yes 19:45
if your class.new accepts named arguments, is it would by default
Poohman I keep getting "cannot look up objects in a xxxx type object" 19:46
19:51 wamba joined
lizmat objects? not attributes 19:54
?
19:54 Tirifto left
lizmat m: class A { has $!a; method a() { $!a } }; A.a 19:54
camelia Cannot look up attributes in a A type object
in method a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat Poohman: that's the one ? ^^^
Poohman lizmat : yes 19:55
Xliff m: my $sub = -> |c { c.gist.say }; $sub('a', 2, π)
camelia \("a", 2, 3.141592653589793e0)
lizmat then you probably forgot to instantiate an object somewhere
Xliff m: my $sub = -> |c { |c.gist.say }; $sub('a', 2, π) 19:56
camelia \("a", 2, 3.141592653589793e0)
Xliff m: my $sub = -> |c { |c.gist.say }; $sub('a', [1, 2, 3], π)
camelia \("a", [1, 2, 3], 3.141592653589793e0)
Poohman im trying to instantiate it inside method a
Xliff m: sub printargs( *@a ) { .gist.say for @a }; my $sub = -> |c { printargs(|c) }; $sub('a', [1, 2, 3], π) 19:57
camelia a
1
2
3
3.141592653589793
Xliff m: sub printargs( +@a ) { .gist.say for @a }; my $sub = -> |c { printargs(|c) }; $sub('a', [1, 2, 3], π)
camelia a
[1 2 3]
3.141592653589793
lizmat Poohman: maybe make a gist ?
Poohman m: class B {has $.a is rw; method b() {self.new(a => "test")}}; my B $temp; $temp.b();say $temp.a; 20:10
camelia Cannot look up attributes in a B type object
in method a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat Poohman: you probably want 'my B $temp .= new' rather than 'my B $temp' 20:11
the latter just sets a type constraint on the $temp, it does *not* create an object 20:12
m: my Int $a; say $a
camelia (Int)
Poohman m: class B {has $.a is rw; method b() {self.new(a => "test")}}; my B $temp .= new; $temp.b();say $temp.a; 20:13
camelia (Any)
Poohman but in that case new will be used twice
is that ok? 20:14
lizmat hmmm.... good point... lemme look closer :-)
20:14 sena_kun left
lizmat I guess I'm not sure what you want to achieve 20:15
do you want to achieve an alternate object instantiation method ? 20:16
m: class A { has $.a; method b() { self.new( a => "test" ) } }; dd A.b
camelia A.new(a => "test")
20:20 Xliff left
Poohman Lizmat: Im trying to introspect the data member attributes and generate the user input and then instantiate the object 20:23
lizmat but how can you inspect data members if you haven't instantiated yet ? 20:24
Poohman im just checking the datatypes etc and then im trying to get the corresponding user input - for example if the data member is of type Date, I make sure the user input is of the correct type 20:25
then using the generated hash im trying to instantiate 20:26
m: class A { has $.a; method b() { self.new( a => "test" ) }; say self }; my A $temp; $temp.b(); 20:28
camelia 5===SORRY!5=== Error while compiling <tmp>
'self' used where no object is available
at <tmp>:1
------> 3od b() { self.new( a => "test" ) }; say 7⏏5self }; my A $temp; $temp.b();
expecting any of:
argument list
Poohman m: class A { has $.a; method b() { self.new( a => "test" ); say self }}; my A $temp; $temp.b(); 20:29
camelia (A)
Poohman m: class A { has $.a; method b() { self.new( a => "test" ); say self.a; }}; my A $temp; $temp.b();
camelia Cannot look up attributes in a A type object
in method a at <tmp> line 1
in method b at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat self inside method "b" is a type object. 20:30
it's *not* an instantiated object
20:30 sena_kun joined
Poohman ok 20:30
lizmat and a type object does not have any attributes
which is what the error message is trying to tell you :-)
my A $temp; $temp.b will *not* automagically make $temp an instantiated object 20:31
you *can* do that, if that's what you want
m: class A { has $.a; method b(\SELF:U:) { SELF = self.new(a => "test") } }; my A $foo; $foo.b; dd $foo 20:32
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix = instead.
Did you make a mistake in Pod syntax?
at <tmp>:1
------> 3A { has $.a; method b(\SELF:U:) { SELF =7⏏5 self.new(a => "test") } }; m…
lizmat m: class A { has $.a; method b(\SELF:) { SELF = self.new(a => "test") } }; my A $foo; $foo.b; dd $foo 20:33
camelia A $foo = A.new(a => "test")
lizmat \SELF: means assigning the name SELF to the un-decontainerized invocant, which you can assign to 20:34
perhaps better readable: 20:35
m: class A { has $.a; method b($invocant is rw:) { $invocant = self.new(a => "test") } }; my A $foo; $foo.b; dd $foo
camelia A $foo = A.new(a => "test")
Poohman m: class A { has $.a; method b($invocant is rw:) { $invocant = self.new(a => "test") } }; my A $foo; $foo.b; dd $foo; say $foo.a; 20:37
camelia A $foo = A.new(a => "test")
test
20:41 RobRaku left
Poohman was reading up on $invocant 20:42
cool
lizmat: thanks
21:11 RobRaku joined 21:27 rindolf left 21:55 Kaeipi left 21:56 Kaeipi joined
lizmat m: dd ∞i # expressiveness :-) 22:07
camelia <0+Inf\i>
chloekek p6: dd 0+Inf\i 22:09
camelia <0+Inf\i>
22:14 sena_kun left 22:25 ircforandroid joined, ircforandroid left 22:28 sena_kun joined 22:35 stoned75 joined, wamba left
chloekek bisectable6: class A { }; class B { }; multi sub infix:<cmp>(A $a, B $b) { Order::More }; multi sub infix:<cmp>(B $b, A $a) { Order::Less }; [A.new, B.new].sort.say 22:36
bisectable6 chloekek, On both starting points (old=2015.12 new=5c65a12) the exit code is 0 and the output is identical as well
chloekek, Output on both points: «(A.new B.new)␤»
22:37 RobRaku left
chloekek bisectable6: class A { }; class B { }; multi sub infix:<cmp>(A $a, B $b) { Order::More }; multi sub infix:<cmp>(B $b, A $a) { Order::Less }; [B.new, A.new].sort.say 22:39
bisectable6 chloekek, On both starting points (old=2015.12 new=5c65a12) the exit code is 0 and the output is identical as well
chloekek, Output on both points: «(A.new B.new)␤»
22:39 libertas joined
chloekek p6: multi f(Int $x) { say 'Int' }; sub g($x) { f($x) }; sub h { multi f(Str $x) { say 'Str' }; g('a') }; h 22:51
camelia Cannot resolve caller f(Str:D); none of these signatures match:
(Int $x)
in sub g at <tmp> line 1
in sub h at <tmp> line 1
in block <unit> at <tmp> line 1
23:01 stoned75 left 23:06 kensanata joined
SmokeMachine xinming_: github.com/FCO/Red/blob/master/t/3...-columns.t 23:14
23:17 kensanata left
SmokeMachine xinming_: now it's implemented... :) 23:20
23:22 chloekek left 23:28 sena_kun left