🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | 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 8 June 2022.
Khwarizmi Is anyone available to answer a few beginner questions? #raku-beginner seems dead 01:34
cmburn Sorry if this is a stupid question, I *want* to use raku, but is there a maintained web framework out there? Best I can tell, only one I saw was abandoned 06:32
Currently use Mojolicious
kjp cmburn: The usually used web solution for raku is cro -- cro.services 06:35
cmburn Oh great, I hadn't seen that at all, all I'd seen was Bailador which seemed dead 06:38
Thanks!
:) 06:39
Guest3 Is there any way to replace a method with augment? Still trying the same as yesterday, but "Cannot have a multi candidate for 'message' when an only method is also in the package 'X::Syntax::Confused'" 09:07
m: augment class X::Syntax::Confused { method message() { "I am confused" } } 09:08
camelia ===SORRY!=== Error while compiling <tmp>
augment not allowed without 'use MONKEY-TYPING'
at <tmp>:1
------> augment class X::Syntax::Confused⏏ { method message() { "I am confused" }
expecting any of:
generic role
09:08
Guest3 m: use MONKEY; augment class X::Syntax::Confused { method message() { "I am confused" } }
camelia ===SORRY!=== Error while compiling <tmp>
Package 'X::Syntax::Confused' already has a method 'message' (did you mean to declare a multi method?)
at <tmp>:1
lizmat m: class X::Foo is X::Syntax::Confused { method message { "I am foo" } } # why not subclass ? 09:22
camelia ( no output )
Guest3 I want to change compile time errors' messages 09:36
There's not much usefulness to this so it's not a big problem if that's not possible 09:37
lizmat Guest3: why do you want to change them? Do you think they're unclear / wrong? 09:38
if that's the case, maybe a PR would be a better solution ?
Guest3 Just for fun, to see how much Raku's internals can be changed, just like we can change the grammar 09:41
lizmat well, you appear to be going for one of the most difficult ones: changing the error message of a compile-time error 09:42
then again: 09:44
m: class X::Syntax::Confused is X::Syntax::Confused { method message() { "foo" } }; 32 45
camelia ===SORRY!=== Error while compiling <tmp>
foo
at <tmp>:1
------> fused { method message() { "foo" } }; 32⏏ 45
expecting any of:
infix
infix stopper
statement end
statement modifier
lizmat but that would only be in *that* lexical scope
Guest331 lizmat: sorry, lost my internet (and nickname apparently) 09:47
Guest331 Is there any way to change the compile time error message? 09:47
lizmat m: class X::Syntax::Confused is X::Syntax::Confused { method message() { "foo" } }; 32 45
camelia ===SORRY!=== Error while compiling <tmp>
foo
at <tmp>:1
------> fused { method message() { "foo" } }; 32⏏ 45
expecting any of:
infix
infix stopper
statement end
statement modifier
lizmat create a subclass with the same name :-) will work lexically 09:48
m: class X::Syntax::Confused is X::Syntax::Confused { method message() { "foo: " ~ callsame } }; 32 45
camelia ===SORRY!=== Error while compiling <tmp>
foo: Two terms in a row
at <tmp>:1
------> d message() { "foo: " ~ callsame } }; 32⏏ 45
expecting any of:
infix
infix stopper
statement end
sta…
Guest331 Damn that's awesome 09:49
lizmat generally speaking: if you want to make changes to the language in a lexical scope, that's pretty easy 09:50
changing things globally is a different ballpark and generally not advisable
Guest331 Why can't I augment a non-multi method tho? Also why can't I augment roles? 09:52
lizmat again, you can do that lexically 09:55
m: role Associative does Associative { }
camelia ( no output )
Guest331 Why doesn't augment allow this?
lizmat as to the why? because it introduces action at a distance, and that is generally thought to not be a good thing 09:56
Guest331 Isn't augmenting class an action at a distance too? 09:58
lizmat indeed 10:03
whereas lexical subclassing isn't 10:04
Guest331 Then allowing augmenting of classes but not of roles
lizmat well, augment was decided upon very early in the development process of Raku 10:08
but later, when pre-compilation of modules was developed, turned out to be a design mistake
well, at least in my opinion :-)
in a language without pre-compilation, and everything is looked up at runtime, this is different, such as in e.g. Perl 10:09
need to go afk now&
nine If augmenting is the answer to your problem, you may be trying to solve the wrong problem 10:18
Geth doc/operator-table-fix: 68ca383047 | (Daniel Mita)++ (committed using GitHub Web editor) | assets/js/main.js
Fix precedence table ordering

Table header names changed in #4031. Closes #4085.
10:25
doc: m-dango++ created pull request #4086:
Fix precedence table ordering
10:26
Guest331 augment should be deprecated, shouldn't it? 11:10
Anton Antonov At some I heard in this forum the idea to implement a global setting that prevents random order in hash objects. Is this considered in a more serious manner or it is still "just an idea" ? 15:28
At some point I heard in this forum the idea to implement a global setting that prevents random order in hash objects. Is this considered in a more serious manner or it is still "just an idea" ?
japhb Depends what you mean. Associatives are sorted when writing keys out during precomp, so that precomp is repeatable. There are also Hash::Ordered and Map::Ordered modules if you want to have associatives in your own code that track insert order (I use Hash::Ordered fairly regularly, in fact). 16:53
Anton Antonov @japhb Thank you! I will try Hash::Ordered in next 1h... 17:02
Voldenet I don't think it's sane idea to depend on order of hashes 17:05
japhb Voldenet: There are definite use cases for ordered hashes. For example guaranteed round-trip ordering from unsorted inputs such as config files, so that any changes your code makes to the config hashes don't trash the user's layout. 17:14
Anton Antonov @Voldenet Depends what you want to do. Mathematica, Python, R and have ordered hashes -- very useful feature in data wrangling and visualizations and machine learning algorithms. 17:15
@Voldenet Depends what you want to do. Mathematica, Python, and R have ordered hashes -- very useful feature in data wrangling and visualizations and machine learning algorithms.
Voldenet but it is usually more useful to simply use arrays or lists 17:16
Sure, you get bad Big-Theta lookups with simply using iterables 17:17
but you can just extract (ref -> index) hash for faster lookups 17:18
japhb Voldenet: One idiom I use is to load data from a file into an ordered hash, so I get the associative I need elsewhere without forgetting the file's ordering, and then cache the .keys and .values from that ordered hash into positionals or iterables for use where those are what I want instead. 17:25
So I get the ordering, the associativity, and the steady-state performance. 17:26
Voldenet Ha, I don't even use the ordered hash
japhb In that case, you're probably doing something similar, with extra steps. :-) 17:27
Voldenet m: my @foo = "A".."X"; my &m = {.ord}; @foo.map(&m).first(* ~~ 70).say; my %k = @foo.map({ m($_) => $_ }); say %k{70}
camelia 70
F
Voldenet that's basically what I do 17:28
imo using a library _is_ an extra step
m: my @foo = "A".."X"; my &m = {.ord}; @foo.first({ m($_) ~~ 70 }).say; my %k = @foo.map({ m($_) => $_ }); say %k{70} 17:29
camelia F
F
Voldenet more like this
japhb I mean ... to each their own, I suppose. 17:30
Voldenet In the core Hash::Ordered works similarly, but it's hard to apply different indexing strategies that way 17:33
so I believe that keeping things as plain data structures inside a class allow easier performance tweaks later
m: my @foo = "A".."X"; my &m = {.ord}; @foo.first({ m($_) ~~ 70 }).say; my %k = @foo.kv.map({ m($^v) => $^i }); say @foo[%k{70}] 17:38
camelia F
F
Voldenet that's what would Hash::Ordered do 17:39
Anton Antonov @Voldenet When I try to execute your first two code examples above I am get the error: [No such method 'ord' for invocant of type 'Any']. (Sorry for being ignorant...) The last one works.
Voldenet hm, that would mean that &m was executed without topic variable 17:42
it's possible that `my &m -> $_ {.ord};` would work
erm
`my &m = -> $_ {.ord};`
(it's not directly the style I use, I just posted it as an example of the approach I use) 17:46
Anton Antonov I think during copy-and-paste some characters got lost. On my Discord window I see the code giving errors as [email@hidden.address] m($) => $ })" -- I assume it has to be "$_" , not "$". 17:47
I think during copy-and-paste some characters got lost. On my Discord window I see the code giving errors as "@foo.map({ m($) => $ })" -- I assume it has to be "$_" , not "$".
Nemokosch Yeah
Voldenet Ah, that makes sense 17:48
Anton Antonov @Voldenet Thanks for posting those examples -- I am trying to _not_ use Hash::Ordered.
Nemokosch I don't see why using a library (whatever even counts as a library and not the language itself) would be an extra step anyway 17:49
Also, in Python, the ordering in hashes made it to the standard, for example 17:50
Voldenet I've got this irrational fear of dependencies caused by seeing too many react projects 17:51
m: role Indexed[$indexer] { method AT-KEY($k) { self.first({ $indexer($_) ~~ $k }) }; }; my $a = [] but Indexed[{.ord}]; $a.push("a"); say $a{97} 17:52
camelia a
moritz Voldenet: call it "learned" and not "irrational"
Nemokosch Well it's rather a Pavlovian reflex 17:55
"Learned" in that sense
Voldenet indeed :)
Nemokosch When you implement something by hand, that can very well be a "dependency" - an internalized one 17:57
As long as you depend on stuff you are really using, it definitely has certain advantages (as well)
Voldenet it can lead to reinventing the wheel (along with the cart, the horse and the road) 18:00
Nemokosch This reminds me of the "wisdom culture" in the programmer community 18:03
It's so common to have visionary opinions about programming languages, infrastructure, paradigms and so on 18:04
And honestly they are often interesting 18:06
But they have to be taken with multiple grains of salt because your average wise programmer likes to reduce their model so that only their one key vision remains
Voldenet It's always specific to problems encountered in the past 18:10
Nemokosch And often those problems are viewed through the lens of some preconception 18:14
Which, again, may not be a problem but it's definitely worth keeping in mind
Just take a look at the Perl-Raku split... 18:16
Voldenet true, the split only was needed because of the preconception that p6 will eventually replace p5 18:22
and the insanity is that p7 is only caused by that as well 18:23
Nemokosch And then everyone has strong feelings and some wisdom why Perl failed, didn't fail, sucks, sticks, you name it 18:47
Geth doc: uzluisf++ created pull request #4088:
Fix URL (#4087)
21:34
p6steve m: sub sbv( %h --> Seq ) {%h.sort(*.value).map(*.key)}; my %x = %(a=>2,b=>0,c=>1); %x.&sbv.say; 21:40
camelia (b c a)
p6steve # sorts Hash by value, returns keys (poor woman's Ordered Hash)
m: sub sbv(%h) {%h.antipairs.sort.map(*.value)}; my %x = %(a=>2,b=>0,c=>1); %x.&sbv.say; 21:50
camelia (b c a)
p6steve (first seems more legible to me) 21:51
Voldenet but not "ordered" like search tree, but "retrievable by stored order" 22:02
p6steve I like this because (i) can use standard raku Hash forward as eg. an index from column label to column number very fast and clear, (ii) sort on column labels is native raku sort on couple hundred items - quite quick (0.95s for 100,000 pairs) 22:05
Voldenet: that's right - but my main use case is forward lookup as an index (label => col id) and I imagine that a native raku hash is fast in this direction, the ordered aspect is secondary (eg. to view a list of column name), and is cheap and stateless to do it this way 22:10
and I like that hashes are deliberately unordered -- that means there are two just concepts Array || Hash that can be blended to do a wide range of behaviours 22:15
(too much perl in my youth) 22:20
Geth docker: MadcapJake++ created pull request #49:
Update Rakudo Star to 2022.04
23:17