timo i saw that the latest version of python got a method to BaseException called "add_note" where you can attach a string to an exception that will be printed below the traceback when the exception is outputted, as well as a getter for the notes that are on an exception 11:59
that seems kind of useful to have? though maybe it'd be nice to have something structured rather than just strings 12:00
especially if you have a different exception printer, like one that outputs exceptions as json
also i stumbled upon python's `except*` syntax, which lets you react to a type of exception that's contained inside of an ExceptionGroup 12:01
lizmat isn't that what "does" does ? 12:02
$exception does annotation("foobar"
with role annotation { $.annotation } 12:03
and then do $exception.?annotation ?
timo that could do. then the annotation role would do something so that the annotations also show up in the message presumably 12:16
lizmat well, yeah, the error reporting would need to do the if self.?annotation -> $annotation { ... } bit 12:28
timo so it would probably want to be part of rakudo, then? if it is meant to be useful 12:34
lizmat well, the $exception.?annotation bit can be added without any problems 12:35
whether an "annotation" role should be added to the core, I'm less sure 12:36
although any lexically defined role would take precedence of on in the core... so ...hmmm
fwiw, such an annotation role would be generally usable 12:37
timo not very useful to add an annotation role if it isn't displayed unless there's code everywhere to check for it
also, adding more than a single annotation would be good, so adding each annotation with "does" is maybe not the best thing
lizmat m: role annotation { has Str $.annotation }; my $a = "foo" but annotation("bar'); say $a.annotation 12:38
camelia ===SORRY!=== Error while compiling <tmp>
Cannot use variable $a in declaration to initialize itself
at <tmp>:1
------> $a = "foo" but annotation("bar'); say $<HERE>a.annotation
expecting any of:
argument list
double qu…
timo instead, Exception could have a method like "annotate" or even "add-note" that mixes in the annotation role to self if it's not there yet and otherwise just adds the thing
lizmat m: role annotation { has Str $.annotation }; my $a = "foo" does annotation("bar'); say $a.annotation
camelia ===SORRY!=== Error while compiling <tmp>
Cannot use variable $a in declaration to initialize itself
at <tmp>:1
------> $a = "foo" does annotation("bar'); say $<HERE>a.annotation
expecting any of:
argument list
double qu…
timo your quotes are mismatched
lizmat m: role annotation { has Str $.annotation }; my $a = "foo" does annotation("bar"); say $a.annotation 12:39
camelia bar
lizmat m: role annotation { has Str $.annotation }; my $a = "foo" but annotation("bar"); say $a.annotation
camelia bar
timo m: role annotation { has Str $.annotation; only method message() { callsame ~ " ($.annotation)" } }; my $e = X::AdHoc.new("blargh!") but annotation("testing"); say $e.message 12:40
camelia Default constructor for 'X::AdHoc' only takes named arguments
in block <unit> at <tmp> line 1
timo m: role annotation { has Str $.annotation; only method message() { callsame ~ " ($.annotation)" } }; my $e = X::AdHoc.new(message => "blargh!") but annotation("testing"); say $e.message 12:41
camelia Too many positionals passed; expected 0 arguments but got 1
in method message at <tmp> line 1
in block <unit> at <tmp> line 1
timo well that's not right
m: role annotation { has Str $.annotation; only method message() { callsame ~ " ($.annotation)" } }; my $e = X::AdHoc.new(payload => "blargh!") but annotation("testing"); say $e.message
camelia Too many positionals passed; expected 0 arguments but got 1
in method message at <tmp> line 1
in block <unit> at <tmp> line 1
timo m: role annotation { has Str $.annotation; only method message() { callsame() ~ " ($.annotation)" } }; my $e = X::AdHoc.new(payload => "blargh!") but annotation("testing"); say $e.message 12:42
camelia blargh! (testing)
timo m: role annotation { has Str $.annotation; only method message() { callsame() ~ " ($.annotation)" } }; my $e = X::OutOfRange.new() but annotation("testing"); say $e.message
camelia Argument out of range. Is: <unknown>, should be in <unknown> (testing)
timo that doesn't seem too bad at first glance 12:43
lizmat would probably add a newline, but yeah 12:44
with that, it could be an ecosystem module
timo did we ever have a "dba" that could be used to make stack traces that are more human-friendly? i seem to recall ... something
lizmat doesn't recall 12:45
timo it might have been something that can go into grammars, in the long-ago-times. maybe in STD? 12:49
i wonder if raku would benefit from something like ExceptionGroup, or if it makes more sense to use Failure objects inside a structure for this purpose. though then there's nothing cheap that can check "is anything in this arbitrarily deeply nested structure of arrays and hashes a Failure?". in general, that strikes me as something that would need careful speccing 12:52
lizmat ah, yes, there's definitely a "dba" "doing business as" annotation there, at least in the legacy grammar
timo ExceptionGroup is an exception by itself, so it is thrown and that's how it reaches your exception handlers
lizmat I don't think the new Raku grammar has / needs as much, as the RakuAST tree is basically the annotation 12:53
timo we do have X::Comp::Group, but that's obviously for compile errors and warnings
lizmat yeah, and there's also something for erorrs thrown inside a thread, to be rethrown somewhere else ?
timo there is where? 12:54
i think you can pass an "uncaught exception handler" to Thread.new or so? and for start{}-ed stuff there's of course the Promise that can be rejected with an exception
OK i gotta run an errand that will take me a frustrating amount of driving time 12:56
lizmat drive safely!
ttyl
timo always :)
lizmat rakkable: eco-provides frobnicate 14:04
rakkable lizmat, Looking for 'frobnicate' using 'eco-provides', please be patient!
lizmat, Found 8 lines in 4 files (4 distributions):
lizmat, gist.github.com/9d8489cbfa63787c61...74138406fe
lizmat rakkable: eco-provides frobnicate 14:09
rakkable lizmat, Looking for 'frobnicate' using 'eco-provides', please be patient!
lizmat, Found 8 lines in 4 files (4 distributions):
lizmat, gist.github.com/6fd78c8a51dcf621f3...676d439653
lizmat rakkable: help 14:10
rakkable lizmat, Rakking on #raku-dev with Raku module IRC::Client::Plugin::Rakkable 0.0.1
lizmat, Currently supported: eco-code | eco-doc | eco-provides | eco-tests | eco-scripts | unicode query [rak args]
lizmat rakkable: help 14:27
rakkable lizmat, Rakking on #raku-dev with Raku module IRC::Client::Plugin::Rakkable 0.0.1
lizmat, Currently supported: eco-code | eco-doc | eco-provides | eco-tests | eco-scripts | unicode query [rak args]
lizmat, Please put any suggestions / bug reports in github.com/lizmat/IRC-Client-Plugi...le/issues. Thank you!
jdv be neat if there was a man page or some sort of longer form doc 14:35
lizmat I've only got 10 fingers :-) 14:36
but you're right :-)
jdv it just popped into my head when i realized idk what that help output really means. but i don't mean to make work for anyone else. its fine:) 14:39
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2025/02/10/2025-06-its-a-bot/ 14:44
timo my first thought about the slow grammar compilation is that it's probably making a tremendously large NFA for LTM purposes? i don't immediately see many things that terminate LTM 16:47
oh actually <td> might do 16:49
oh those are also all tokens, and tokens have ratchet don't they?
lizmat I think so ? 16:51
timo actually, td doesn't terminate LTM because <Comment> doesn't, and that's one of the options 16:52
Stage parse : 0.316 - with a {} before the contents of "token td" 16:55
Stage parse : 1.753 - without changes from the code on glot.io
0.901 vs 11.587 after uncommenting RelationalExpression and one of the two EqualityExpressions 16:58
uncommented a few more, ram is rising steadily as it compiles ... 16:59
81.378 but now i actually had the {} in td, not sure what exactly happened there. presumably a path that lets you go through different things without hitting a td 17:01
Geth nqp/main: e76ec6cc4b | (Elizabeth Mattijsen)++ | tools/templates/MOAR_REVISION
Bump MoarVM to get string utf8 decode tweak

  MasterDuke++
18:55
lizmat eco-code terminal 19:05
rakkable: eco-code terminal
rakkable lizmat, Looking for 'terminal' using 'eco-code', please be patient!
lizmat, Found 1040 lines in 206 files (101 distributions): 19:06
lizmat, gist.github.com/977fda533e8e89ac92...5902171982
lizmat lucs: ^^
timo i've been letting it run, it'? now at 2:15h run time, 32.5 gigabyte ram usage 19:18
lizmat wow 19:19
timo gist.github.com/timo/3f3926c6e42b6...72ba747991 here's a stack trace i grabbed at a random spot 19:48
lizmat 832 -> 951 ad infinitum 19:51
hmmm
timo yeah it recursively merges substates of NFAs together 19:52
mergesubrule / mergesubstates
here i have an array with 158627822 entries 19:53
lizmat that's.... a lot :-)
timo the first entry is also an NQPArray 19:54
and it looks like it's spending a huge amount of time in GC at this point 19:55
or that could just be where it's easiest to hit when pressing ctrl-c 19:58
lizmat in any case, a keeper in the sense of: a potentially golfable case of grammar slowness 20:00
meh
timo i'd assume this is also related to the reason why we have EXPR and not a classical recursive descent parser for operator precedence parsing 20:01
lizmat possibly 20:02
timo after this whole merging of stuff is done, there's also going to be a run of the optimizer on this NFA
haha. 96% of time spent in VMArray_gc_mark
lizmat having that plough through 32G of data, isn't going to go fast either 20:03
timo nope.
i have decided against outputting the states to a .dot and rendering it to a png 20:05
because i only have a few terabytes of hard drive space left :P
lizmat yeah, that feels... wise :-) 20:11
timo i freed up a lot of ram and i'm going to let it continue running to see how it changes in its behaviour
lizmat you're feeling adventurous ! :-) 20:12
timo maybe it could be good to have something like a little check with a before/after timing of creating an NFA and if it's a very long time, output some information, like what NFAs are being merged together and why 20:15
or a check in the merge functionality when it goes above 500k states or 1m states
lizmat well, if it survives the legacy and Raku grammars... those are among the largest... 20:16
right?
timo well, their NFAs aren't, i don't think?
this mechanism would help figure out when something goes into "accidentally bonkers" territory 20:18
lizmat would you want to do this in spesh, or in the NFA mechanism itself, keeping counters and such ? 20:19
timo neither
this would be in nqp
oh the cpu usage just dropped off a whole lot
lizmat OOM ? 20:20
timo something about its behaviour is changing
i still have 18 gig "available"
i think it might have taken something out of swap 20:21
in any case, cpu usage went up again soon after i mentioned that 20:22
Geth rakudo/main: 553bd7566c | (Elizabeth Mattijsen)++ | 2 files
Make $() work properly on scalar values

  - let Mu.item return a container if there is none yet
  - make sub item() actually return containers (is raw was missing)
  - make the sub item version call the method item, for consistency
All spectest clean. ... (14 more lines)
20:36
lizmat m: sub a($x is rw) { $x++; dd $x; $x }; a($[1,2]) 20:48
camelia Parameter '$x' expects a writable container (variable) as an argument,
but got '[1 2]' (Array) as a value without a container.
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat that error feels wrong?
m: dd $[1,2]
camelia $[1, 2]
Geth rakudo/main: e34b767fd7 | (Elizabeth Mattijsen)++ | 4 files
Remove now unnecessary .item methods

The same semantics now apply to **all** objects, not just to Iterables, Captures and QuantHashes
20:58
lucs lizmat: Oh, eh, thanks :) 21:27
lizmat yeah, I think it was down at the moment you tried it, it didn't generate a gist afaics 21:28
lucs I was just wondering roughly what it does. 21:29
Now I see what eco-code does, eh. 21:30
lizmat rakkable: help 21:31
rakkable lizmat, Help sections available: eco-code eco-doc eco-provides eco-scripts eco-tests
lizmat, unicode version.
lizmat rakkable: help eco-code
rakkable lizmat, Search all of the code of the active distributions in the ecosystem
lizmat, which is the sum of 'eco-provides', 'eco-tests', 'eco-scripts'
lucs Aha, gotcha.
lizmat added a little help section
rakkable: unicode heart 21:32
rakkable lizmat, Looking for 'heart' using 'unicode', please be patient!
lizmat, Found 52 matches
lizmat, gist.github.com/d3393f1c4a6fc69292...405e354c6f
lizmat if you're ever in need of a heart symbol :-)
lucs Oh, nice. 21:33
Hmm... "Knight" of hearts is "C", since K is already taken by King. 21:35
Probably "C" for French "Cavalier". 21:36
In chess problems, it's the letter "S" (for German "Springer") that was chosen.
(In the English speaking community anyway.)
Now, with gazillions of chess players online, it's moving to "N" (they know nothing of over a century of chess problems history). 21:37
lizmat hehe