🦋 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:00
Doc_Holliwood left
|
|||
Xliff | moritz: Since you were interested before - gist.github.com/Xliff/23d83c2ddcfc...c572caa87d | 00:03 | |
00:05
cpan-raku left
00:06
cpan-raku joined,
cpan-raku left,
cpan-raku joined
|
|||
stoned75 | what was the reason for github.com/rakudo/rakudo/commit/42...bb0bed2fb9 ? | 00:10 | |
lizmat | stoned75: because, just as Lists, Maps can have containers as values, and are thus potentially mutable, and thus not value objects | 00:12 | |
stoned75: see also: github.com/rakudo/rakudo/pull/3331 | 00:13 | ||
stoned75 | ok. I see. obvious ! thanks ! | ||
ah. and of course Dict is not yet documented :-) | 00:17 | ||
ah but it's not merged, silly me | |||
00:22
melezhik left
|
|||
lizmat | yeah... it will be a little while still | 00:23 | |
00:29
brtastic left
00:48
pecastro left
01:07
guifa2 joined
01:17
stoned75 left
01:43
guifa2 left
01:48
jmchael left
|
|||
kawaii | Hello, I'm trying to use the YAMLish module to turn the contents of this document (github.com/mybb/mybb.com/blob/gh-p...mbers.yml) into a hash, using the `username` attribute as the key but using the `load-yaml` method only ever gives me one large item, any ideas? It strikes me that YAML seems difficult to parse compared to JSON | 02:02 | |
02:06
seanrobert joined
|
|||
Xliff | gist.github.com/Xliff/fcf214158ad5...25b9b72dc0 | 02:15 | |
^^ jnthn sena_kun | |||
kawaii: Looking... one sec. | 02:16 | ||
kawaii | Xliff: thanks, appreciate it :) | 02:18 | |
Xliff | kawaii: Are you using YAML or YAML::Parse? | ||
kawaii | Xliff: github.com/Leont/yamlish | ||
YAMLish | |||
If there's another module I'm happy to try :) | |||
02:21
seanrobert left
|
|||
Xliff | kawaii: OK. What comes out is an array of hash objects | 02:22 | |
You will need to further process it if you want it to be a hash, | |||
my $o = load-yaml("test.yml".IO.slurp); my %h = (gather for $o[] { take Pair.new(.<username>, $_); }).Hash | 02:24 | ||
kawaii | Xliff: ahhh I see my mistake, I was doing load-yaml directly into a hash object | 02:26 | |
thank you so much, this is perfect | |||
Xliff | You're welcome! | ||
tony-o: You still around? | 02:32 | ||
Is there a way to check if a dynamic variable exists? | 02:35 | ||
02:35
guifa2 joined
02:42
mowcat left
|
|||
sortiz | m: say defined($*VM), defined($*FooBar) # Xliff | 02:42 | |
camelia | TrueFalse | ||
Xliff | sortiz++ | 02:43 | |
ThanksMuch | |||
sortiz | YW | ||
guifa2 | Note that that won't tell you if it exists | 03:07 | |
only that it is undefined | |||
my $*a = Str; say defined $*a | |||
evalable6 | False | ||
03:08
asymptotically left,
asymptotically joined
03:14
JRaspass left
|
|||
guifa2 | Xliff: you'll actually want to use '$*foo' (elem) CALLERS::.keys | 03:15 | |
03:17
berber44 joined
|
|||
guifa2 | (there may be another way by accessing the stash — I think vrurg was working on that, but I feel like this is the most idiomatic way to get it | 03:17 | |
vrurg | m: say $*NOVAR.raku; | 03:19 | |
camelia | Failure.new(exception => X::Dynamic::NotFound.new(name => "\$*NOVAR"), backtrace => Backtrace.new) | ||
vrurg | m: my $*ADYNAMIC = pi; say DYNAMIC::<ADYNAMIC>:exists; | 03:20 | |
camelia | False | ||
vrurg | Hm... | ||
m: my $*ADYNAMIC = pi; say DYNAMIC::<$*ADYNAMIC>:exists; | 03:22 | ||
camelia | True | ||
guifa2 | ah duh, I always forget about that adverb | ||
Although I think CALLER could be better than DYNAMIC | 03:24 | ||
If you declare the variable in the same scope, but later somehow, it seems to still give you true | 03:25 | ||
actually no, CALLERS still gives true, at least in REPL | 03:26 | ||
03:26
Xliff left
|
|||
vrurg | guifa2: callers would give you not only dynamics, if memory serves me right. | 03:28 | |
m: my $foo = 42; sub foo { say CALLERS::<$foo>; }; foo; | |||
camelia | 42 | ||
vrurg | m: my $foo = 42; sub foo { say DYNAMIC::<$foo>; }; foo; | ||
camelia | 42 | ||
vrurg | 6e: my $foo = 42; sub foo { say DYNAMIC::<$foo>; }; foo; | 03:29 | |
m: use v6.e.PREVIEW; my $foo = 42; sub foo { say DYNAMIC::<$foo>; }; foo; | |||
camelia | Don't know setting RESTRICTED at gen/moar/ModuleLoader.nqp:249 (/home/camelia/rakudo-m-inst-1/share/perl6/lib/Perl6/ModuleLoader.moarvm:previous_setting_name) from gen/moar/ModuleLoader.nqp:254 (/home/camelia/rakudo-m-inst-1/share/perl6/lib/… |
||
vrurg | Ok, 6.c/6.d do have some problems which are going to be there for backward compat. But 6.e must be different. | 03:32 | |
Sorry, my bad. The difference between DYNAMIC and CALLERS is the former also lookups in the current scope whereas CALLERS starts with the caller scope. | 03:35 | ||
guifa2 | vrurg: yeah, that's why I was thinking CALLERS might be better because UNIT includes post-declared variables | 03:41 | |
and I can imagine in a recursive routine, someone doing if CALLERS::<$*foo>:exists { do one thing } else { my $*foo = 5; callsame } or something like that | 03:42 | ||
guifa2 actually did basically exactly that with one of his modules | |||
I guess in that case the else block is separate, but the declaration could happen separately somewhere in the same scope | 03:43 | ||
03:53
berber44 left
04:53
nativecallable6 left,
benchable6 left,
unicodable6 left,
committable6 left,
greppable6 left,
linkable6 left,
notable6 left,
bloatable6 left,
releasable6 left,
statisfiable6 left,
evalable6 left,
tellable6 left,
bisectable6 left,
quotable6 left,
squashable6 left,
shareable6 left,
coverable6 left,
sourceable6 left
04:54
benchable6 joined,
coverable6 joined,
greppable6 joined,
sourceable6 joined,
linkable6 joined,
evalable6 joined
04:55
shareable6 joined,
bisectable6 joined,
squashable6 joined,
nativecallable6 joined,
unicodable6 joined,
quotable6 joined
04:56
bloatable6 joined,
statisfiable6 joined,
notable6 joined,
tellable6 joined
04:57
committable6 joined,
releasable6 joined
05:27
seanrobert joined
05:36
seanrobert left
05:43
rindolf joined
05:52
sortiz left
06:10
k-man joined
06:32
guifa2 left
06:33
parabolize left
06:49
brtastic joined
|
|||
notandinus | when should i break a script into modules? | 06:53 | |
it's ~162 lines | 06:54 | ||
moon-child | notandinus: when it becomes difficult to maintain in unified form | ||
notandinus | i see, so i'll just keep it as single script | 06:58 | |
no need for zef right if it's a single script? | |||
07:04
jmerelo joined
|
|||
notandinus | what does * before @ signify? | 07:11 | |
sub MAIN(*@test) | |||
^^ in this? | |||
jmerelo | notandinus: it makes it a slurpy docs.raku.org/type/Signature#Slurpy_parameters | 07:23 | |
07:24
frost-lab joined
07:30
sjm_uk joined
07:34
wamba joined,
sena_kun joined
07:35
Sgeo left
|
|||
notandinus | i see, thanks | 07:37 | |
07:47
ufobat joined
07:54
aborazmeh joined,
aborazmeh left,
aborazmeh joined,
domidumont joined
07:58
notagoodidea joined
07:59
brtastic left
08:03
wamba left
08:11
stoned75 joined
08:31
MasterDuke joined
08:32
abraxxa1 joined
|
|||
notagoodidea | I have this messy line that I am sure there is a better way to code: | 08:33 | |
`.grep(/TODO/) ?? s/TODO/DONE/ !! s/DONE/TODO/ if .grep /$todo/ for @todos; ` | 08:34 | ||
@todos is a array of string with the format "(TODO|DONE) XXXX" and $todo is a string | |||
any suggestion to for in-place modification and get rid of the `.grep ?? !!` pattern ? | 08:36 | ||
08:37
abraxxa1 left
08:38
abraxxa1 joined
|
|||
jmerelo | notagoodidea: well, there's always a loop... You can use rw loop variables. | 08:51 | |
m: constant $VER = 3; class Foo:ver{$VER} {}; | |||
camelia | Block object coerced to string (please use .gist or .raku to do that) |
||
jmerelo | Hum | ||
m: constant $VER = v3; class Foo:ver{$VER} {}; | 08:53 | ||
camelia | Block object coerced to string (please use .gist or .raku to do that) |
||
notagoodidea | jmerelo: something like : `for @todos -> $t is rw { * }`? | ||
jmerelo | notagoodidea: right | ||
m: constant VER = v3; class Foo:ver{VER} {}; | 08:54 | ||
camelia | Block object coerced to string (please use .gist or .raku to do that) |
||
jmerelo | m: constant VER = v3; class Foo:ver{VER} {}; say Foo.^ver | ||
camelia | Block object coerced to string (please use .gist or .raku to do that) v |
||
jmerelo | m: constant VER = 3; class Foo:ver{VER} {}; say Foo.^ver | ||
camelia | Block object coerced to string (please use .gist or .raku to do that) v |
||
jmerelo | m: constant auth = "Þor"; class Foo:auth{auth} {}; say Foo.^auth | 08:55 | |
camelia | -> ;; $_? is raw = OUTER::<$_> { #`(Block|68336832) ... } | ||
notagoodidea | my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { s/foo/bar/ }; say @foo; | 08:56 | |
m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { s/foo/bar/ }; say @foo; | |||
camelia | Use of uninitialized value of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. [foo 1 bar 2] in block at <tmp> line 1 Use of uninitialized value of type Any in string con… |
||
jmerelo | m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f ~~ s/foo/bar/ }; say @foo; | 08:57 | |
camelia | [bar 1 bar 2] | ||
jmerelo | notagoodidea: ^^^ remember s by default acts on the context variable. | ||
08:59
ufobat left
|
|||
notagoodidea | right! Maybe is it clear to do `{ $f .= subst() }` in this case. | 08:59 | |
09:00
ufobat joined
|
|||
notagoodidea | m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/foo/, "bar") }; say @foo; | 09:00 | |
camelia | [bar 1 bar 2] | ||
09:01
Doc_Holliwood joined
|
|||
notandinus | Str $action, #= action to perform (ex. backup, rotate)) | 09:01 | |
*@profiles, #= profiles to perform the action on | |||
# Str $profile, | |||
Bool :v(:$verbose), #= increase verbosity) | |||
Bool :$version, #= print version | |||
); | |||
oof, sorry for the paste, i was trying to paste the link | 09:02 | ||
ix.io/2L8U | |||
^ can i make --help display the sub-actions? | |||
09:02
ufobat left
|
|||
MasterDuke | i think you can define your own USAGE | 09:03 | |
notagoodidea | notandinus: check bduggan.github.io/meta-perl6-cli/#31 | ||
MasterDuke | docs.raku.org/language/create-cli#...ntry-USAGE | ||
09:05
pecastro joined
|
|||
notagoodidea | m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/1/, "bar") if .grep(/foo/) }; say @foo; | 09:06 | |
camelia | Use of uninitialized value of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. [foo 1 bar 2] in block at <tmp> line 1 Use of uninitialized value of type Any in string con… |
||
notagoodidea | m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/1/, "bar") if $f.grep(/foo/) }; say @foo; | ||
camelia | [foo bar bar 2] | ||
notagoodidea | m: my @foo = ["foo 1", "bar 2"]; for @foo -> $f is rw { $f .= subst(/bar/, "lala") if $f.grep(/foo/) }; say @foo; | ||
camelia | [foo 1 bar 2] | ||
09:08
ufobat joined
|
|||
MasterDuke | m: my @foo = ["foo 1", "bar 2"]; for @foo.grep("foo") -> -> $f is rw { $f .= subst(/bar/, "lala") }; say @foo | 09:09 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Missing block at <tmp>:1 ------> 3 1", "bar 2"]; for @foo.grep("foo") -> -7⏏5> $f is rw { $f .= subst(/bar/, "lala") |
||
MasterDuke | m: my @foo = ["foo 1", "bar 2"]; for @foo.grep("foo") -> $f is rw { $f .= subst(/bar/, "lala") }; say @foo | ||
camelia | [foo 1 bar 2] | ||
notagoodidea | han :D | ||
MasterDuke | your `$f.grep` is trying to do a list operation on a string | 09:10 | |
you probably want `$f.contains` | 09:11 | ||
09:11
JRaspass joined
|
|||
notagoodidea | I certainly want it now :) | 09:11 | |
thanks | |||
MasterDuke | np | ||
notandinus | MasterDuke: notagoodidea: thanks, | 09:16 | |
how do i get "where" part for this param? &MAIN.signature.params[0] | 09:20 | ||
Str $action where * ∈ <backup rotate> | |||
^ it's defined like this, .params[0] is $action, i need <backup rotate> part from it | 09:21 | ||
so that i don't have to define it twice, i'm going to define my own USAGE | |||
jmerelo | notandinus: not sure it's accessible. It might be, though... | ||
notandinus | when i print &MAIN.signature.params[0], it does say | 09:22 | |
MasterDuke | create a subset first and use it in both? | ||
notandinus | Str $action where { ... } | ||
MasterDuke: i see, i'll check that | |||
jmerelo | notandinus: um, that would be a Parameter type, and it does have a .constraints method. docs.raku.org/type/Parameter Give it a try. It might be .signature.params[0].constraints | 09:23 | |
09:24
aluaces joined
|
|||
notandinus | jmerelo: all(WhateverCode.new) | 09:25 | |
MasterDuke | i think it comes from github.com/rakudo/rakudo/blob/mast...n.pm6#L208 | ||
notandinus | that returns ^ | ||
i'm trying the subset thing | |||
notagoodidea | notandinus: from there bduggan.github.io/meta-perl6-cli/#38 and the fact that `MAIN("alice")` is behind the hood `MAIN(Str $foo where {$foo eqv "alice"}` | 09:26 | |
jmerelo | notandinus: right, it's not terribly helpful... Mainly you can't extract individual elements out of a Junction, I think. Introspection can only take you so far... | 09:27 | |
notandinus | notagoodidea: ah i forgot that, thanks | 09:28 | |
yeah it's a junction thingy | 09:29 | ||
i've defined a subset like this: subset Action of Str where * ∈ <backup rotate>; | |||
notagoodidea | Don't you will have the same issue to access the value of the Junction there ? | 09:30 | |
notandinus | oh wait, i could just define an array @actions now and put <backup rotate> in it, | ||
notagoodidea: yeah not a good idea ;) | |||
notagoodidea | notandinus: That's what I have done when I played with it. | ||
`my @sub = <foo bar> ; ... MAIN(Str $sub where { * eqv any @sub });` | 09:31 | ||
notandinus | wait then i don't have to bother with subset | ||
notagoodidea | But maybe an enum is better there ? | ||
notandinus | yeah i'lll just do where * ∈ @actions | ||
notagoodidea: i don't know what an enum is , i'll check it out | 09:32 | ||
notagoodidea | I was just looking at it yesterday so, pinch of salt because I am not sure to have a full grasp of the enums in Raku | ||
notandinus | hmmi also need to have description for each action, i'll make it a hash for now | 09:35 | |
hmm the enum thing is working fine | 09:41 | ||
using a subset will work the same way right? | |||
09:41
Altai-man joined
|
|||
notandinus | or even a constant @array | 09:42 | |
09:44
sena_kun left
|
|||
notagoodidea | notandinus: for the MAIN part yes. With a subset you will call it `MAIN(Action $str, ..)` | 09:46 | |
I just don't know if it convinient for the USAGE after, or just harcode it somewhere. | 09:47 | ||
09:47
aborazmeh left
|
|||
notandinus | notagoodidea: enum looks good, i made it an enum | 09:48 | |
enum Actions ( backup => "make a backup) | 09:49 | ||
^ this way i can just use the hash directly to print usage | |||
and restrict it too | |||
notagoodidea | Is there a profiler for raku? | 10:01 | |
notandinus | yeah, just run --profile | 10:02 | |
10:04
brtastic joined
|
|||
notandinus | ok so i need a --version flag | 10:15 | |
$action needs to be passed all the time except when --version is passed, how do i define this? | 10:16 | ||
i can make a multi MAIN, is that the best way? | |||
notagoodidea | maybe you will have to make $action optional, I am not sure how the multi sub dispatch with positional parameters & flags? | 10:24 | |
notandinus: I remember, multi sub yes but you will need to have a general case MAIN to call USAGE when to params are passed or it will dispatch on the sub with the version flag (or the last flag). | 10:33 | ||
or not. | 10:34 | ||
notandinus | notagoodidea: i've defined it like: multi sub (Bool :$version) {} multi sub (Action $action,... ) {} | 10:36 | |
and it seems to work fine | |||
i added is-hidden-from-USAGE in first multi and added a :$version to second multi too so that it comes up in usage | |||
when --version is passed, first multi gets called, 2nd one is all other cases. | 10:37 | ||
notagoodidea | mm, notandinus this minimal version always dispatch on :$version sub (outputing "ALPHA") when called without parameters : pastebin.com/S0N4QzgF | 10:45 | |
but I don't know why. | 10:47 | ||
kawaii | Does Raku have some built-in way to check the age of a variable or when it was last written to/updated? | 10:50 | |
MasterDuke | dispatching with named variables can be a little tricky, recommend reading docs.raku.org/language/functions#i...i-dispatch | 10:51 | |
notandinus | notagoodidea: hmm yeah , no t sure why | ||
MasterDuke | kawaii: no, but istr someone wrote a module to do something similar | ||
samebchase- | kawaii: no, you'll need to define your own object which keeps tracks of updates or use a module as MasterDuke suggested | 10:52 | |
kawaii | Okie, thanks :) | ||
notandinus | mine is : paste.debian.net/hidden/59ff407b/ | ||
and it dispatches on second multi in all cases except when --version is passed | |||
11:04
linkable6 left,
evalable6 left
11:06
evalable6 joined,
linkable6 joined
11:10
Black_Ribbon left
|
|||
notagoodidea | notandinus: Does yours call USAGE on empty parameters ? | 11:12 | |
11:13
moony joined
|
|||
notagoodidea | MasterDuke: For what I see, because named argument prevails on arity, the dispatch will always go to the named argument. | 11:14 | |
So for MAIN, it is a bit weird because it will output the first flag it will dispatch against. | 11:18 | ||
11:23
sjm_uk left
|
|||
notagoodidea | mm, it is not that weird in fact if one want to reproduce a command like `ls` but to mimic `git` and call the help when no parameters provided, we must use a catch-all flag at the beginning of the multi-dispatch to call USAGE. | 11:24 | |
notandinus | notagoodidea: yeah it calls USAGE on empty params | 11:33 | |
notagoodidea: oh wait | 11:36 | ||
it doesnt | |||
i dunno why i was saying it does, so i'll have to add an empty multi MAIN? | 11:37 | ||
11:45
asymptotically left
|
|||
notagoodidea | notandinus: That will not work like in my example. If I understand multi dispatch correctly, named argument seems to prevails. A solution seems to be to put a named argument on top of all and made him call USAGE like 'multi sub MAIN(Bool :$help-implied) { say $*USAGE }` before the multi calling version for you. | 11:48 | |
11:50
asymptotically joined,
jmchael joined
|
|||
notandinus | notagoodidea: i see, thanks. that works fine, one could also do `$version ?? say "Leo v0.6.0" !! USAGE();` right? | 11:51 | |
11:56
olve joined
11:58
wamba joined
|
|||
notagoodidea | notandinus: than works yep. | 12:02 | |
SmokeMachine | m: sub toggle(@a, $name) { @a.grep(*.contains: $name).map: { .subst-mutate: /^ (DONE|TODO)/, { %(DONE => "TODO", TODO => "DONE"){ $_ } } } }; my @a = "TODO xxx", "DONE yyy"; say @a; toggle @a, "xxx"; say @a; toggle @a, "yyy"; say @a | 12:09 | |
camelia | [TODO xxx DONE yyy] [DONE xxx DONE yyy] [DONE xxx TODO yyy] |
||
SmokeMachine | notagoodidea: ^^ | 12:10 | |
12:12
Doc_Holliwood left
|
|||
notagoodidea | Oh you can provide Hash to subst! | 12:12 | |
SmokeMachine | on that case, that's a block... | 12:13 | |
notagoodidea | There is a warning on subst-mutate no? | ||
SmokeMachine | not that I'm aware of.. | ||
notagoodidea | docs.raku.org/routine/subst-mutate > NOTE: .subst-mutate is deprecated in the 6.d version, and will be removed in future ones. You can use subst with .= method call assignment operator or s/// substitution operator instead. | 12:14 | |
SmokeMachine | m: say "blablelbibloblu".subst: /a|e|I|o|u/, *.uc | ||
camelia | blAblelbibloblu | ||
SmokeMachine | m: say "blablelbibloblu".subst: :g/a|e|I|o|u/, *.uc | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Preceding context expects a term, but found infix , instead. at <tmp>:1 ------> 3 "blablelbibloblu".subst: :g/a|e|I|o|u/,7⏏5 *.uc |
||
SmokeMachine | m: say "blablelbibloblu".subst: :g, /a|e|I|o|u/, *.uc | 12:15 | |
camelia | blAblElbiblOblU | ||
SmokeMachine | m: sub toggle(@a, $name) { @a.grep(*.contains: $name).map: <-> $a { $a .= subst: /^ (DONE|TODO)/, { %(DONE => "TODO", TODO => "DONE"){ $_ } } } }; my @a = "TODO xxx", "DONE yyy"; say @a; toggle @a, "xxx"; say @a; toggle @a, "yyy"; say @a | ||
camelia | [TODO xxx DONE yyy] [DONE xxx DONE yyy] [DONE xxx TODO yyy] |
||
SmokeMachine | notagoodidea: without substantiation-mutate: ^^ | 12:16 | |
notagoodidea | ok, I got how the block works. | 12:17 | |
12:17
olve_ joined
|
|||
SmokeMachine | (sorry, subst-mutate) | 12:18 | |
notagoodidea | And i forgot <-> instead of `is rw`. | ||
The surface of Raku feels endless sometimes | |||
12:19
olve left
|
|||
Altreus | hello, what's this <-> | 12:19 | |
notagoodidea | <-> mark the parameters of the block as rw. | 12:20 | |
Altreus | oh, the doc search actually understands punctuation | ||
that's a pleasant surprise | |||
that's a super helpful thing to know! | 12:21 | ||
12:31
MasterDuke left
13:15
guifa2 joined
13:22
aborazmeh joined,
aborazmeh left,
aborazmeh joined
13:25
MasterDuke joined
13:34
jmerelo left
13:42
sena_kun joined
13:43
Altai-man left
13:45
olve_ left
13:53
xelxebar left
13:57
wamba left
14:01
abraxxa1 left
14:05
frost-lab left
14:08
abraxxa1 joined
14:09
wamba joined
14:13
mowcat joined
14:18
sno left
14:21
sno joined
14:25
abraxxa1 left
14:26
aborazmeh left,
xelxebar joined
14:27
mowcat left
14:31
abraxxa1 joined
14:35
cpan-raku left
14:36
abraxxa1 left
14:37
domidumont1 joined
14:40
domidumont left
14:44
rindolf left
14:45
cpan-raku joined,
cpan-raku left,
cpan-raku joined
14:54
Sgeo joined
14:57
Tirifto joined
14:59
abraxxa1 joined
15:07
rindolf joined
|
|||
Tirifto | Hello! Is my understanding right that re-dispatching a call to .new to a parent class via ‘callsame’ will result in the class’ own BUILD/TWEAK/bless (sub)methods not being called? | 15:15 | |
15:16
aborazmeh joined,
aborazmeh left,
aborazmeh joined
|
|||
guifa2 | They should be called because callsame is still taking place in the original new scope | 15:23 | |
Tirifto | Ah, looks like I’m missing something else then. Thank you, guifa2! | 15:25 | |
15:25
tech_hutch joined
|
|||
guifa2 | Well, I just tested it, but I do kind of agree — something does feel off | 15:25 | |
tech_hutch | Hello | 15:27 | |
🦋 | |||
guifa2 | greetings tech_hutch! | 15:28 | |
Tirifto | Howdy! 🦆️ | ||
[Coke] wonders if he can change his nick to 🥤 | 15:30 | ||
15:31
Doc_Holliwood joined
|
|||
tech_hutch | So I was trying out the REPL, and things seemed a little odd | 15:31 | |
tbrowder | yo, all, anyone else having trouble with github workflow tests? | ||
perry | [Coke] you could always do U+1F964 | ||
tbrowder | for their modules? | ||
tech_hutch | It says `Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.12.` Is that just my terminal encoding being set wrong? | ||
perry | tech_hutch: ha. probably. | 15:32 | |
tech_hutch | Like, is it trying to say Raku in Japanese or something? lol | ||
perry | tech_hutch: here's what it looks like for me: i.imghurr.com/e/MDUrObsPHx.png | ||
tbrowder | i'm getting "operation cancelled" when zef is searching for dependencies | 15:33 | |
tech_hutch | Ohhh okay. So it's using some odd Unicode chars | ||
perry | It's UTF-8. Mathematical bold letters. | ||
tech_hutch | `~` is the string concatenation operator, right? and so `~=` would concatenate and reassign? | 15:35 | |
I'm getting some strange results. Sometimes when I do, e.g., `my $thing = "hi"` `$thing ~= " there"`, subsequently doing `$thing` prints "hi there there", "hi there there there", etc. | 15:37 | ||
Is this just a repl bug? | |||
perry | tech_hutch: not sure what you mean. This is what I see: i.imghurr.com/e/mZMDMTPDbl.png | 15:38 | |
15:39
parabolize joined
|
|||
tech_hutch | Sometimes that happens for me (which is what I'd expect), but other times I get the weird behavior I just described | 15:39 | |
I'm new to IRC, can I upload images here? | |||
perry | I think webchat is through kiwi, so I think so | 15:40 | |
Tirifto | tech_hutch: Ha, I just got the same behaviour as you! (Or similar, at least.) | ||
15:40
perryprog-pg joined,
perryprog-pg is now known as perryprog-dg
|
|||
tech_hutch | I don't see any way to upload | 15:40 | |
15:40
perryprog-dg left
|
|||
perry | Huh. I don't either. | 15:41 | |
tech_hutch | Here's an image I uploaded to Discord yesterday (I think you can see it without an account): media.discordapp.net/attachments/2...nknown.png | ||
perry | Huh. That's interesting. | 15:42 | |
Tirifto | tech_hutch, perry: Here’s the output of mine: zerobin.net/?dc0bb01b57eb7c7d#DQYg...PyUc3oI8Q= | ||
perry | Doing the exact same thing Tirifto, I get different output | 15:43 | |
notagoodidea | it doe not incremet "there" on mine. | ||
perry | notagoodidea: that's cause you're cool like me | 15:44 | |
Tirifto, is this also in Powershell? | |||
notagoodidea | <3 | ||
tech_hutch | It's not doing it for me now | ||
Tirifto | :P | ||
notagoodidea | Here it's rakudo 2020.02 / 6.d on Fedora with fish. | ||
tech_hutch | The cool kids don't experience repl bugs 😎 | ||
perry | notagoodidea, same here but macOS | 15:45 | |
and also Fish :) | |||
tech_hutch | Mine is PowerShell through Windows Terminal | ||
notagoodidea | perry: indeed like you :D | ||
perry | tech_hutch, can you reproduce it with either 1) the text Tirifto sent or 2) in a different terminal emulator? | ||
Tirifto | I’m running Rakudo 2020.12 in Bash on Parabola GNU/Linux-libre (derived from Archlinux), installed with the help of AUR (a community package repository). | ||
perry | This bug has nerd-sniped me I think | 15:46 | |
Oh wow that's weird | |||
Tirifto | Oh wait. | ||
perry | Oh my Rakudo might be out of date then. Just realized I'm on 0.10. | 15:47 | |
2020.10* | |||
Tirifto | I may actually be running a non-release version. | ||
perry gasps | |||
Tirifto | I do recall installing 2020.12 and finding it oddly slow to start, so I tried installing the version from master, and I might be running that now… but that said, 2020.12 did feel kind of weird right from the start. | 15:48 | |
tech_hutch | perry yes, exactly the same output for me | 15:49 | |
perry | waaaaaat | ||
tech_hutch | cdn.discordapp.com/attachments/250...nknown.png | ||
Tirifto | tech_hutch: Did you install the ordinary Rakudo 2020.12 release version? | 15:50 | |
MasterDuke | the repl has always been a bit odd and had bugs unique to itself. lizmat++ made some changes recently, so there might be new behavior | 15:53 | |
15:53
abraxxa1 left
15:54
[Coke] joined,
[Coke] left,
[Coke] joined
|
|||
lizmat | yes, the REPL has new quirks :-) | 15:55 | |
tech_hutch | Tirifto yeah, from here rakudo.org/downloads | ||
perry | "surprise features" | ||
[Coke] | oof, that was weird. on mac. jostled something, got an alert that the external drive with everyone's home dirs on it needs to be shut down before you unplug it. it was still connected, but my Dock preferences were all reset. weird. | 15:56 | |
tech_hutch | I just worry bugs like this would confuse a newcomer (like me) even more | 15:57 | |
Tirifto | I can confirm that ‘hi there’ works as expected in a script. | ||
tech_hutch | That's good, at least | ||
MasterDuke | i just checked and that odd behavior doesn't happen on 2020.08 | 15:58 | |
tech_hutch | Also, you know what would be cool? A place online where you can try out Raku without downloading anything, like a lot of other languages have | ||
(unless there is one and I missed it) | |||
15:59
guifa2 left
|
|||
[Coke] | there is. one sec. | 15:59 | |
tyil | glot.io has Raku support, no? | ||
MasterDuke | m: say "hi" | ||
camelia | hi | ||
15:59
guifa2 joined
|
|||
tyil | tech_hutch: glot.io/new/raku | 15:59 | |
MasterDuke | also run.tio (or tio.run, can never remember the order) | ||
tyil | tio.run iirc | ||
don't think .tio is a valid tld (yet) | 16:00 | ||
tech_hutch | ah cool. the site should link there | ||
[Coke] | (one sec until others fill in the URL, thanks. :) | 16:01 | |
Tirifto | p6: my $thing = “hi”; $thing ~= “ there”; say $thing; say $thing; $thing ~= “ there”; say $thing; say $thing; | ||
camelia | hi there hi there hi there there hi there there |
||
Tirifto | The evalbot is safe. :-) | ||
MasterDuke | those are linked from raku.org/resources/ | ||
guifa2 | Is there any way to substr a str and get a str back (that is, avoiding boxing)? | 16:02 | |
tech_hutch | MasterDuke ah ok. Still would be nice to link it more prominently. E.g., Go has one embedded right in the homepage | 16:03 | |
MasterDuke | i think there is a doc issue about similar ideas (e.g., make the examples in the docs runnable/editable) | 16:04 | |
github.com/Raku/doc/issues/1866 | 16:07 | ||
El_Che | tio is uncle in spanish | 16:08 | |
notagoodidea | m: say "foo bar".WHAT; say "foo bar".subst(/foo", "baz").WHAT; | 16:10 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1) at <tmp>:1 ------> 3 say "foo bar".subst(/foo", "baz").WHAT;7⏏5<EOL> expecting … |
||
notagoodidea | m: say "foo bar".WHAT; say "foo bar".subst(/foo/, "baz").WHAT; | ||
camelia | (Str) (Str) |
||
MasterDuke | guifa2: maybe if you nqp ops directly | 16:11 | |
*use | 16:12 | ||
guifa2 | MasterDuke: I was afraid that'd be the answer lol. Trying to avoid nqp | ||
MasterDuke | fwiw, Strs and strs are pretty similar, not like int and Int | 16:13 | |
why don't you want the boxing? | |||
16:14
aborazmeh left,
Doc_Holliwood left
|
|||
[Coke] | Is there interest in having a sort algorithm like tcl's [lsort -dictionary]? ("in -dictionary mode, bigBoy sorts between bigbang and bigboy, and x10y sorts between x9y and x11y.") | 16:15 | |
could do it as a sub for folks to pass to .sort... | 16:16 | ||
tech_hutch | oh, so this language has autoboxing? | ||
MasterDuke | tech_hutch: yep | 16:18 | |
16:18
mowcat joined
|
|||
guifa2 | Masterduke: I know the boxing and unboxing are extra ops that I'd like to avoid — I'm doing an sprintf-like operation, and I'm playing around with different things to keep it is nimble as possible. Using native ints can be a massive speed up, so I was hoping I might get similar out of strs | 16:18 | |
MasterDuke | m: my int $a = 4; say $a.WHAT | ||
camelia | (Int) | ||
MasterDuke | ^^^ the int variable was autoboxed to an Int when the method was called | 16:19 | |
guifa2: i think it'd be a tiny difference | |||
[Coke] | m: my str $a = "eek"; say $a | 16:20 | |
camelia | eek | ||
guifa2 | I think I can pull off the algorithm to avoid substrs, but at the cost of more math, so I'll need to test the trade off perf wise | 16:23 | |
guifa2 . o O ( formatting numbers is a lot more complicated than one might think! ) | |||
Tirifto | On that note, how do you tell whether or not it’s been autoboxed? | 16:24 | |
guifa2 | m: my Str $a = 'a'; my str $b = 'a'; say $a.VAR.WHAT; say $b.VAR.WHAT | 16:25 | |
camelia | (Scalar) (StrLexRef) |
||
Tirifto | Oh, nice! | 16:26 | |
16:27
aluaces left
|
|||
tech_hutch | do functions only take the boxed versions? | 16:29 | |
guifa2 | They can take unboxed, but they have to declare them, and they can't distinguish between different types | ||
so sub foo (int64 $foo) { … } will take an int64, int32, int16, etc | 16:30 | ||
You have to be very conscientious when working with natives to avoid getting them boxed (basically, you have to strongly type your code that uses them) | 16:32 | ||
MasterDuke | generally you're not supposed to care | ||
tyil | >You have to be very conscientious when working with natives to avoid getting them boxed | 16:33 | |
that's a good sentence when taken out of context | |||
16:34
aluaces joined
|
|||
tadzik | :o | 16:34 | |
guifa2 | Yeah, what MasterDuke said is very true. The idea of Raku is for the average person to not even think of the native/closer-to-metal-y stuff | 16:35 | |
I would never write a normal script using it, but there's also a tradition of developers (core and modules) torturing themselves to benefit the end-user/programmer, so for those situations, it cna make sense to work harder to eek out certain benefits | 16:36 | ||
tech_hutch | Hm okay | 16:38 | |
@ty | |||
(whoops) | 16:39 | ||
tyil I thought the same thing haha | |||
"so sub foo (int64 $foo) { … } will take an int64, int32, int16, etc" guifa2 oh, so the smaller int types subclass the bigger ones? | 16:41 | ||
16:41
cpan-raku left,
vike joined
|
|||
Tirifto | If I want something to happen every time a class is instantiated (no matter how), would putting it in BUILD/TWEAK/bless be the way to go? (It seems like those should be inherent to the instantiation mechanism, or at least close to it.) | 16:43 | |
MasterDuke | no, they're not subclasses. fwiw, right now rakudo has some limitations/bugs around how the sized natives are handled (also signed vs unsigned natives) | 16:44 | |
i'd recommend TWEAK, but yeah, you could use almost any of those. TIMTOWTDI | 16:47 | ||
Tirifto | In that case, am I missing something in expecting this to say ‘Hello!’? | 16:49 | |
p6: class Binode is IO::Path { submethod TWEAK () {say ‘Hello!’} }; Binode.new(‘/usr/bin/raku’); | |||
camelia | ( no output ) | ||
notagoodidea | Every time, I read TIMTOWTDI as Tim tows Teddy. | ||
MasterDuke | m: class F { submethod TWEAK() { say "F: " ~ self.^name; }; }; my $b = F.new; my $c = F.new; class G is F { submethod TWEAK() { say "G: " ~ self.^name }; }; my $d = G.new | 16:54 | |
camelia | F: F F: F F: G G: G |