This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:12 deoac joined
deoac Has anyone considered adding `either` to `none`, `any`, `one`, and `all` ? 00:13
guifa What would either do? 00:36
is that just all/or with a two item list? 00:37
Nemokosch controversial(?) take: we need *less* English in junctions, not more 01:03
"one" and "all" are mathematically precise enough to be universally useful 01:07
with "none", I'm more or less okay with, it can be a legitimate option 01:08
but "any" is just too vague as a word for... well, anything 😆
one day, I will hopefully get to writing a "petition to remove negation lifting", and then I will definitely include the vagueness of "any" as one of the arguments against the status quo 01:11
04:00 razetime joined 04:30 Heptite left 04:35 Heptite joined 04:48 MasterDuke joined 04:57 Heptite left 05:02 Heptite joined 05:07 Heptite left
jaguart um: Cannot find method 'find_method' on object of type NQPParametricRoleHOW 05:22
from: if $what.HOW ~~ Metamodel::AttributeContainer
and: if $what.HOW.does(Metamodel::AttributeContainer) ===> Too few positionals passed; expected 3 arguments but got 2 05:35
05:41 deoac left
Kaiepi jaguart, try Metamodel::Primitives.is_type: $what.HOW, Metamodel::AttributeContainer 06:25
NQPParametricRoleHOW backs nqp's roles. it's bare to the point of not being Mu or having its ACCEPTS method needed for a smartmatch
or even being able to locate such a method 06:26
CIAvash what Kaiepi said and maybe `$what.HOW.does: $what.HOW, Metamodel::AttributeContainer` or `$what.HOW.^does: Metamodel::AttributeContainer`. Also how is Metamodel related to #raku-beginner? 06:57
08:29 razetime left
jaguart CIAvash: thanks - I guess it's beginner because I am trying to understand how modules and classes work in Raku? and this is for my introspection exercise 08:39
Kaiepi: thanks, works :) 08:45
09:03 dakkar joined, alethkit left
jaguart This fails: $what.WHO<EXPORT>:exists -> but this works: $what.WHO.EXISTS-KEY(<EXPORT>) - I thought $what.WHO returned the stash - where am I going wrong? 09:09
Nemokosch What CIAvash asked... sure this is beginner stuff? 😅 09:11
jaguart I get confused by what I think is and adverb test on a hash not working vs calling a .EXISTS-KEY() - so I'm thinking hash access is beginner /shrug? 09:13
should I move this to the #raku then? 09:14
Nemokosch re adverb - in what context did that appear? adverbs have notoriously low precedence 09:15
jaguart am I using wrong term? in ' $what.WHO<EXPORT>:exists' I was calling :exists the adverb 09:16
Nemokosch yes, I mean is this the whole expression in appeared in?
say there was an infix ~ in front of it - that would probably already hijack the adverb 09:17
jaguart its a simple trailing-if - {...} if $what.WHO<EXPORT>:exists; 09:18
Nemokosch now that's interesting 09:19
jaguart what confuses me is that is false, but this works as expected: {...} if $what.WHO.EXISTS-KEY(<EXPORT>);
Nemokosch m: class Foo { has %.bar }; my $instance = Foo.new: bar => {a => 'bee' }; say $instance.bar<a>:exists;
jaguart maybe because .WHO is a macroish thing? 09:20
Nemokosch this works for me
what type does it return? 09:21
dakkar m: class Foo { our $thing }; say "ok" if Foo.WHO<$thing>:exists; 09:23
camelia ok
dakkar m: class Foo { our $thing }; say "ok" if Foo.WHO<$wrong>:exists;
camelia ( no output )
dakkar jaguart: like that?
jaguart interesting, when I make a one-liner it works - let me dig deeper in my module 09:24
m: module Foo { sub bar () is export {...} }; my $f = Foo; say $f.WHO<EXPORT>:exists; say $f.WHO.EXISTS-KEY(<EXPORT>);
camelia True
True
Nemokosch I swear this is gonna be some adverb gotcha 09:25
dakkar whatever your module is doing, I agree that `:exists` and `.EXISTS-KEY` should agree
jaguart ok must have been a misstype - now it works, argh 09:30
dakkar all's well that ends well 😜
Nemokosch well I was almost right about the adverb gotcha xd 09:31
jaguart I'll remember to blame adverbs just after bad-fingers 09:32
Nemokosch well not sure how a misstype should change True to False 09:33
unless it's one ! more or less 😄
jaguart given a reference to a package, is there a way to access the package stash without EVAL ? I can do this: EVAL( $what.WHO ~ "::EXPORT::.keys" ) 09:34
actually even easier - is there an interface that enumerates the EXPORTS of a Module/Package? 09:35
Nemokosch I don't know but do you know about :: as an operator? 09:36
jaguart and then I also want an interface that enumerates the roles of a Class or instance?
jaguart rushes to find :: in the docs... 09:37
interesting - I guess you mean docs.raku.org/language/packages#In...into_names - i.e. lookup details from the GLOBAL stash :: 09:38
oh - it says this is not global namespace lookup... thanks for the pointer, I will explore this 09:39
Nemokosch not sure it's really an "operator" but one thing is sure - you can access any stash with this postfix :: syntax
iirc this postfix :: is exactly the same as .WHO, just nicer
Did I mention that workshop from Vadim 2021? 09:40
This is also something I've seen in that video.
jaguart you did - I have it bookmarked to watch 09:48
This is nicer than .WHO :))) 09:49
Nemokosch anyway, supposedly ::asd is simply a hash lookup on WHO 09:57
dakkar uh… 10:16
m: module Foo { sub x is export {} };Foo::EXPORT()
camelia WARNINGS for <tmp>:
Useless use of constant value Foo::EXPORT() in sink context (line 1)
dakkar m: module Foo { sub x is export {} };say Foo::EXPORT()
camelia (EXPORT(Any))
dakkar m: module Foo { sub x is export {} };say Foo::WHO<EXPORT>()
camelia Could not find symbol '&WHO' in 'Foo'
in block <unit> at <tmp> line 1
dakkar m: module Foo { sub x is export {} };say Foo.WHO<EXPORT>()
camelia Unexpected named argument 'no_fallback' passed
in block <unit> at <tmp> line 1
dakkar that looks like a bug to me
m: module Foo { sub x is export {} };say Foo.WHO<&EXPORT>() 10:17
camelia No such method 'CALL-ME' for invocant of type 'Any'
in block <unit> at <tmp> line 1
dakkar I'm getting confused… /me leaves 10:18
Nemokosch the last one was clear, at least 10:20
you looked up something that didn't exist and therefore got Any back
also, Foo::EXPORT appears to be a type object, the returned value for Foo::EXPORT() hints that it's taken as a type annotation 10:21
m: module Foo { sub x is export {} };say Foo.WHO<EXPORT()> 10:22
I'm curious
okay, this lookup didn't work out
anyway, this is the only one that seemed downright bizarre, with that obscure message
jaguart m: module Foo { sub x is export {} };say Foo.WHO<EXPORT>.HOW 10:35
camelia Perl6::Metamodel::PackageHOW.new
jaguart So Foo.WHO<EXPORT> is a package namespace
m: module Foo { sub x is export {} };say Foo.WHO<EXPORT>.HOW; say Foo.WHO<EXPORT>{::}.keys 10:37
camelia Perl6::Metamodel::PackageHOW.new
(0 1 2 3 4 5 6 7 8 9 10 11)
jaguart and I have no idea what that is
Nemokosch with the parens, it's a coercion
jaguart into a stash? 10:38
jaguart calls it a night - he has Slow Horses to catch
Nemokosch m: module Foo { sub x is export {} };say Foo.WHO<EXPORT>.HOW; say Foo::EXPORT().HOW 10:40
> No such method 'gist' for invocant of type'Perl6::Metamodel::CoercionHOW'
> Foo.WHO<EXPORT>{::}.keys 10:42
I don't know enough to break _that_ down, that's for sure
the {::} part, in particular 10:43
12:41 dakkar left 12:42 dakkar joined
deadmarshal I don't understand how to work with the all function of Raku. I want to return -1 if all list elements are odd. something like: return -1 if so @arr.all !%% 2; 13:27
In Perl it would be: return -1 if all {$_ % 2 != 0} @$arr; 13:28
Nemokosch YES, that's why I want to write that petition, EXACTLY 13:33
by the way, are you an English native? because that would be double irony if you even are 13:34
13:40 mcmillhj joined
the "official" answer is that @arr.none %% 2 will work right 13:44
the "unofficial" answer is that we are facing a deliberate misdesign of negation from Larry Wall 13:45
and "all !%% 2" is silently rephrased into "! all %% 2" 13:46
which I think has bitten WAY too many people to be tolerable
deadmarshal thank u 14:12
15:37 Heptite joined 16:02 mcmillhj left 17:16 jaguart left 17:37 dakkar left 23:44 jaguart joined, jaguart left 23:45 jaguart joined